Project

General

Profile

Feature #16470

Issue with nanoseconds in Time#inspect

Added by andrykonchin (Andrew Konchin) 7 months ago. Updated 13 days ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:96614]

Description

Ruby 2.7 added nanosecond representation to the return value of Time#inspect method.

Nanosecond is displayed as Rational as in the following example:

t = Time.utc(2007, 11, 1, 15, 25, 0, 123456.789)
t.inspect # => "2007-11-01 15:25:00 8483885939586761/68719476736000000 UTC"

The nanosecond value 8483885939586761/68719476736000000 can be expanded to 0.12345678900000001. This is different from the stored nanosecond:

t.nsec # => 123456789
t.strftime("%N") # => "123456789"

I assume it isn't expected, and will be fixed.


Related issues

Related to Ruby master - Bug #16445: Time#inspect shows a fractional numberClosedActions
Related to Ruby master - Feature #15958: Time#inspect with fracClosedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Bug #17025: `Time#ceil` does not work like `Rational#ceil` or `Float#ceil`ClosedActions

Also available in: Atom PDF