Issue #12173 has been updated by Robert A. Heiler.


> I think it would be best for these from_now and until_now methods to return
> a Time object rather than a Float.

I don't know the current way - is it custom for Ruby to return a time object
for time-related methods? I mean it would not be a huge issue, one could call
.seconds to get the seconds.

Anyway +1 on the idea of the initial suggestion above. I have no particular
preferences on the name itself, till_now, until_now but we should all settle
for something in the end.

----------------------------------------
Feature #12173: `Time#till_now`
https://bugs.ruby-lang.org/issues/12173#change-57498

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
It is very frequent to have a time instance:

~~~RUBY
t = Time.now
~~~

and then after some operations, do:

~~~RUBY
Time.now - t
~~~

I propose `Time#till_now`, which is equivalent to:

~~~RUBY
class Time
  def till_now; self.class.now - self end
end
~~~

and similar methods can perhaps be defined on `Date` and `DateTime` classes as well. Another candidate for the method name is `until_now`.

Then we can do:

~~~RUBY
t = Time.now
# some heavy operation
puts "It took #{t.till_now} secs."



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>