Project

General

Profile

Actions

Feature #16470

closed

Issue with nanoseconds in Time#inspect

Added by andrykonchin (Andrew Konchin) about 4 years ago. Updated over 3 years ago.

Status:
Closed
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 3 (0 open3 closed)

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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0