Project

General

Profile

Actions

Bug #8173

closed

2-arg form of Time.at can take a Time as either argument

Added by hasari (Hiro Asari) about 11 years ago. Updated about 11 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-03-11 trunk 39724) [x86_64-darwin12.2.1]
Backport:
[ruby-core:53764]

Description

http://www.ruby-doc.org/core-2.0/Time.html#method-c-at shows 3 forms of invocation:

at(time) → time click to toggle source
at(seconds_with_frac) → time
at(seconds, microseconds_with_frac) → time

But the last form can take a Time as either argument (and converts to a numeric value represented by the number of seconds since the Epoch). If a Time is used as the second argument, the numeric value is then converted to microseconds to return a Time. (I hope that I'm making sense.)

irb(main):001:0> RUBY_DESCRIPTION
=> "ruby 2.1.0dev (2013-03-11 trunk 39724) [x86_64-darwin12.2.1]"
irb(main):002:0> t1=Time.at(10)
=> 1969-12-31 19:00:10 -0500
irb(main):003:0> t2=Time.at(t1,t1)
=> 1969-12-31 19:00:10 -0500
irb(main):004:0> t2.usec
=> 10

Is this intended behavior? If so, the documentation should be updated.

1.9.3 behaves the same way.


Related issues 3 (0 open3 closed)

Related to Ruby master - Bug #8180: Backport r39967 to 1.9.3 and 2.0.xClosed03/28/2013Actions
Related to Backport193 - Backport #8194: Backport r39967Closedusa (Usaku NAKAMURA)04/01/2013Actions
Related to Backport200 - Backport #8193: Backport r39967Closednagachika (Tomoyuki Chikanaga)04/01/2013Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0