Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7, JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre1
    • Component/s: Miscellaneous
    • Labels:
      None
    • Environment:
      jruby 1.7.0.dev (ruby-1.9.3-p139) (2012-04-27 90f43f2) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_31) [darwin-x86_64-java]
    • Number of attachments :
      1

      Description

      Time.now.nsec always returns 0. I'm pretty sure I'm not lucky enough to always call this method on the 0th nsec every time.

      To reproduce this issue, run `Time.now.nsec` a few times and you will get the feeling of being very lucky.

      Anyway, since nsec always returns 0, I cannot roundtrip Time objects in YAML.

      1. test.rb
        0.6 kB
        Aaron Patterson

        Issue Links

          Activity

          Hide
          Hiro Asari added a comment -

          This is basically the same as JRUBY-5676.

          JVM doesn't provide finer temporal granularity than milliseconds, so we can't get a reasonable value.

          Show
          Hiro Asari added a comment - This is basically the same as JRUBY-5676 . JVM doesn't provide finer temporal granularity than milliseconds, so we can't get a reasonable value.
          Hide
          Hiro Asari added a comment -

          Aaron,

          Can you explain the "roundtrip" part?

          Show
          Hiro Asari added a comment - Aaron, Can you explain the "roundtrip" part?
          Hide
          Charles Oliver Nutter added a comment -

          I'm going to reopen this because I think I understand what Aaron means by roundtrip.

          We can't produce Time objects with nsec granularity, but we could at least preserve nsec if it is already present. That should be sufficient, yes?

          Show
          Charles Oliver Nutter added a comment - I'm going to reopen this because I think I understand what Aaron means by roundtrip. We can't produce Time objects with nsec granularity, but we could at least preserve nsec if it is already present. That should be sufficient, yes?
          Hide
          Charles Oliver Nutter added a comment -

          Aaron: Can you provide a test case that tries to roundtrip a Time with nsec >0, so we'll know what we need to pass?

          Show
          Charles Oliver Nutter added a comment - Aaron: Can you provide a test case that tries to roundtrip a Time with nsec >0, so we'll know what we need to pass?
          Hide
          Aaron Patterson added a comment -

          Yes! I can do that.

          Show
          Aaron Patterson added a comment - Yes! I can do that.
          Hide
          Aaron Patterson added a comment -

          time roundtrip tests

          Show
          Aaron Patterson added a comment - time roundtrip tests
          Hide
          Aaron Patterson added a comment -

          I've added two test cases that both pass on MRI 1.9 and both raise exceptions on JRuby master.

          Show
          Aaron Patterson added a comment - I've added two test cases that both pass on MRI 1.9 and both raise exceptions on JRuby master.
          Hide
          Charles Oliver Nutter added a comment -

          I fixed this and nearly all of the tagged Time specs in master@ac0aff5.

          commit ac0aff594c5536bb407ec82511370629d7bef2c9
          Author: Charles Oliver Nutter <headius@headius.com>
          Date:   Mon Apr 30 00:17:52 2012 -0500
          
              Fix JRUBY-6631: Time#nsec always returns 0
              
              RubyTime now uses nsec base for sub-ms time component. We still
              cannot produce times with nsec resolution, but we will preserve
              nsec resolution values if constructed by the user.
              
              I also fixed almost all tagged Time specs in 1.9 mode. The only
              remaining failure is Time#+ adding a negative time, which seems
              to fail due to differences in floating-point precision.
          
          Show
          Charles Oliver Nutter added a comment - I fixed this and nearly all of the tagged Time specs in master@ac0aff5. commit ac0aff594c5536bb407ec82511370629d7bef2c9 Author: Charles Oliver Nutter <headius@headius.com> Date: Mon Apr 30 00:17:52 2012 -0500 Fix JRUBY-6631: Time#nsec always returns 0 RubyTime now uses nsec base for sub-ms time component. We still cannot produce times with nsec resolution, but we will preserve nsec resolution values if constructed by the user. I also fixed almost all tagged Time specs in 1.9 mode. The only remaining failure is Time#+ adding a negative time, which seems to fail due to differences in floating-point precision.

            People

            • Assignee:
              Charles Oliver Nutter
              Reporter:
              Aaron Patterson
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: