class Time

Public Class Methods

since(t) click to toggle source

Returns the number of since since t

# File lib/mug/time.rb, line 47
def since t
  t.to_now
end
until(t) click to toggle source

Returns the number of seconds until t

# File lib/mug/time.rb, line 40
def until t
  t.from_now
end

Public Instance Methods

from_now() click to toggle source

Returns the number of seconds until the time represented by this Time object.

target = Time.new 2117, 1, 1, 0, 0, 0
sleep target.from_now
# File lib/mug/time.rb, line 27
def from_now
  #if time.respond_to? :unix_timestamp
  #  to_i - Time.unix_timestamp
  #else
    self - self.class.now
  #end
end
to_now() click to toggle source

Returns the number of seconds since the time represented by this Time object.

start = Time.now
#...
duration = start.to_now
# File lib/mug/time.rb, line 12
def to_now
  #if Time.respond_to? :unix_timestamp
  #  Time.unix_timestamp - to_i
  #else
    self.class.now - self
  #end
end