JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6809

Time::utc sub-millisecond inaccuracy, causes incorrect date in Rails

    Details

    • Number of attachments :
      0

      Description

      JRuby 1.7.0 Time::utc rounds up nanoseconds, JRuby 1.6.7 does not:

      jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_05) [Windows 7-amd64-java]
      C:\>jruby --1.9 -e 'p Time.utc(2012,7,31,23,59,59,999999.999)'
      2012-07-31 23:59:59 UTC
      
      jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-05-19 00c8c98) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_05) [Windows 7-amd64-java]
      C:\>jruby --1.9 -e 'p Time.utc(2012,7,31,23,59,59,999999.999)'
      2012-08-01 00:00:00 UTC
      

      The rounding causes Rails to create the wrong date when using Time.end_of_month since Rails uses the time of '23,59,59,999999.999' to create the time on the last day of the month, so Time.end_of_month returns the first of the next month.

        Issue Links

          Activity

          Hide
          Hiro Asari added a comment -

          Separating the two distinct issues.

          Show
          Hiro Asari added a comment - Separating the two distinct issues.
          Hide
          Hiro Asari added a comment -

          This is fixed in 0ac40a9. The other (separate) issue originally reported in this ticket was spinned off to JRUBY-6811.

          Show
          Hiro Asari added a comment - This is fixed in 0ac40a9. The other (separate) issue originally reported in this ticket was spinned off to JRUBY-6811 .

            People

            • Assignee:
              Hiro Asari
              Reporter:
              Tim Hayman
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: