Skip to content

Time.new with Rational seconds performs invalid rounding to the next second #8880

@rsim

Description

@rsim

Environment Information

  • jruby 10.0.1.0-SNAPSHOT (3.4.2) 2025-06-27 63db5b3 OpenJDK 64-Bit Server VM 21.0.6+7-LTS on 21.0.6+7-LTS [arm64-darwin]

Expected Behavior

Time.new(2025, 6, 27, 14, 4, Rational(1, 1), 0)
# => 2025-06-27 14:04:01 +0000

Actual Behavior

Time.new(2025, 6, 27, 14, 4, Rational(1, 1), 0)
# => 2025-06-27 14:04:02 +0000

This problem was discovered when using Time.now.change(usec: 0) from activesupport Time extensions.

This is working correctly in JRuby 10.0.0.1 and was working correctly using jruby-head last week.

As I see @enebo has been making Time usec and nsec argument changes in recent days, probably that has broken this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions