Project

General

Profile

Feature #12173

`Time#till_now`

Added by sawa (Tsuyoshi Sawada) almost 5 years ago. Updated almost 5 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:74300]

Description

It is very frequent to have a time instance:

t = Time.now

and then after some operations, do:

Time.now - t

I propose Time#till_now, which is equivalent to:

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:

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

Related issues

Related to CommonRuby - Feature #8640: Add Time#elapsed to return nanoseconds since creationOpen07/16/2013Actions
Related to CommonRuby - Feature #8096: introduce Time.current_timestampFeedbackmatz (Yukihiro Matsumoto)03/15/2013Actions

Also available in: Atom PDF