Project

General

Profile

Feature #16470

Updated by sawa (Tsuyoshi Sawada) almost 4 years ago

Recently in Ruby 2.7 nanoseconds were added nanosecond to a string representation to produced by the return value of `Time#inspect` method. 

 Nanosecond is displayed as `Rational` as in I encountered an issue when was working on new specs for the following RubySpec project - nanoseconds are displaying like a Rational. 

 Let's illustrate it with example: 

 ```ruby 
 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 But nanoseconds are stored nanosecond: correctly: 

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

 So `123456789` is formatted as `8483885939586761/68719476736000000` which equals `0.12345678900000001`. 

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

Back