Project

General

Profile

Actions

Feature #12173

open

`Time#till_now`

Added by sawa (Tsuyoshi Sawada) over 8 years ago. Updated over 8 years ago.

Status:
Open
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 2 (1 open1 closed)

Related to Ruby master - Feature #8640: Add Time#elapsed to return nanoseconds since creationOpenActions
Related to Ruby master - Feature #8096: introduce Time.current_timestampFeedbackmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0