[ruby-core:74308] [Ruby trunk Feature#12173] `Time#till_now`

From: sawadatsuyoshi@...
Date: 2016-03-14 22:24:54 UTC
List: ruby-core #74308
Issue #12173 has been updated by Tsuyoshi Sawada.


Matthew Kerwin wrote:
> Please note that "till_now" is not correct spelling; it should be "until_now" or "til_now"

*till* and *until* are the correct spelling. Perhaps you are confusing with *'til*.


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

* 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next