From: tagomoris@... Date: 2017-09-20T06:50:19+00:00 Subject: [ruby-core:82889] [Ruby trunk Feature#13919] Add a new method to create Time instances from unix time and nsec Issue #13919 has been updated by tagomoris (Satoshi TAGOMORI). `Time.at_nsec` is ok for me, but it seems to take just one argument of nano seconds from epoch. * `Time.at_nsec(nsec_from_epoch)` * `Time.at_nsec(seconds_from_epoch, nsec)` Is it not confusing? Or should it get exactly two arguments? ---------------------------------------- Feature #13919: Add a new method to create Time instances from unix time and nsec https://bugs.ruby-lang.org/issues/13919#change-66788 * Author: tagomoris (Satoshi TAGOMORI) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Time object contains `nsec`, but Time class doesn't have method to create an instance with nsec. Time.at() accepts 2nd argument, but it's micro-sec, and we need to divide nsec by 1000.0. ```ruby t1 = Time.now t1.nsec #=> nsec value t2 = Time.at(t1.to_i, t1.usec) # not nsec! t3 = Time.at(t1.to_i, t1.nsec / 1000.0) # additional division ``` I think it's better to have another method to create an instance from time(unix time) and nsec, for example, `Time.of(unix_time, nsec)` ```ruby t = Time.now Time.of(t.to_i, t.nsec) == t ``` -- https://bugs.ruby-lang.org/ Unsubscribe: