Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.6.8, JRuby 1.7.0.pre1
    • Component/s: None
    • Labels:
      None
    • Environment:
      jruby 1.7.0.dev (ruby-1.9.3-p203) (2012-05-13 8009c04) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      strftime on a time seems to return different results than on a datetime. The result seems to have too many spaces.

      I've attached a test to reproduce the problem.

      1. test.rb
        0.4 kB
        Aaron Patterson

        Activity

        Hide
        Aaron Patterson added a comment -

        Sorry, I should have said what the output is on my machine. Here it is:

        [aaron@higgins psych (jruby)]$ ~/git/jruby/bin/jruby --1.9 -I.:lib:test test.rb
        Run options: --seed 39595

        1. Running tests:

        F

        Finished tests in 0.659000s, 1.5175 tests/s, 1.5175 assertions/s.

        1) Failure:
        test_datetime_formats_the_same_as_time(FormattingTest) [test.rb:9]:
        — expected
        +++ actual
        @@ -1 +1 @@
        -"2010-10-10 00:00:00.000000000 -07:00"
        +"2010-10-10 00:00:00.000000000 -07:00"

        1 tests, 1 assertions, 1 failures, 0 errors, 0 skips

        Show
        Aaron Patterson added a comment - Sorry, I should have said what the output is on my machine. Here it is: [aaron@higgins psych (jruby)] $ ~/git/jruby/bin/jruby --1.9 -I.:lib:test test.rb Run options: --seed 39595 Running tests: F Finished tests in 0.659000s, 1.5175 tests/s, 1.5175 assertions/s. 1) Failure: test_datetime_formats_the_same_as_time(FormattingTest) [test.rb:9] : — expected +++ actual @@ -1 +1 @@ -"2010-10-10 00:00:00.000000000 -07:00" +"2010-10-10 00:00:00.000000000 -07:00" 1 tests, 1 assertions, 1 failures, 0 errors, 0 skips
        Hide
        Hiro Asari added a comment -

        A much short reduction is:

        $ jruby -rdate -e 'p Time.new(2010,10,10).to_datetime.to_time.strftime("%5N %Y")'
        "00000  2010"
        

        Fixed on the master (03150d4) and the 1.6 (6bc0674) branches.

        commit 03150d48008fec3e5fd1e331b84f135eee8523a6
        Author: Hiro Asari <asari.ruby@gmail.com>
        Date:   Sun May 13 22:18:59 2012 -0400
        
            Fix JRUBY-6661: strftime should behave the same for datetime and time
            
            Here, the problem was that when using the '%N' formatter, we did not
            discard it before moving on to the next token. As a result, if the next
            token needs to be formatted wider than the default value, the output is
            skewed.
        
        Show
        Hiro Asari added a comment - A much short reduction is: $ jruby -rdate -e 'p Time.new(2010,10,10).to_datetime.to_time.strftime("%5N %Y")' "00000 2010" Fixed on the master (03150d4) and the 1.6 (6bc0674) branches. commit 03150d48008fec3e5fd1e331b84f135eee8523a6 Author: Hiro Asari <asari.ruby@gmail.com> Date: Sun May 13 22:18:59 2012 -0400 Fix JRUBY-6661: strftime should behave the same for datetime and time Here, the problem was that when using the '%N' formatter, we did not discard it before moving on to the next token. As a result, if the next token needs to be formatted wider than the default value, the output is skewed.

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Aaron Patterson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: