Class Time
In: lib/facets/more/typecast.rb
lib/facets/more/times.rb
lib/facets/core/time/to_date.rb
lib/facets/core/time/to_time.rb
lib/facets/core/time/stamp.rb
lib/facets/core/time/to_s.rb
lib/facets/core/time/change.rb
lib/facets/core/time/elapse.rb
Parent: Object

Methods

Constants

NEVER = Time.mktime(2038)
ZERO = Time.mktime(1972)
FORMAT = { :db => "%Y-%m-%d %H:%M:%S", :dbase => "%Y-%m-%d %H:%M:%S", :datbase => "%Y-%m-%d %H:%M:%S", :utc => "%Y-%m-%d %H:%M:%S", :short => "%d %b %H:%M", :long => "%B %d, %Y %H:%M", :day1st => "%d-%m-%Y %H:%M", :dmYHM => "%d-%m-%Y %H:%M", :rfc822 => "%a, %d %b %Y %H:%M:%S %z", nil => "%a %b %d %H:%M:%S %Z %Y"

Public Class methods

This method calculates the days extrema given two time objects. start time is the given time1 at 00:00:00 end time is the given time2 at 23:59:59:999

Input:

  • the two times (if only time1 is provided then you get an extrema of exactly one day extrema.

Output:

  • the time range. you can get the start/end times using range methods.

Tracks the elapse time of a code block.

  Time.elapse { sleep 1 }  #=> 0.999188899993896

Public Instance methods

Returns a new Time representing the time a number of seconds ago. Do not use this method in combination with x.months, use months_ago instead!

at_beginning_of_day()

Alias for beginning_of_day

at_beginning_of_month()

Alias for beginning_of_month

at_beginning_of_week()

Alias for beginning_of_week

at_beginning_of_year()

Alias for beginning_of_year

at_midnight()

Alias for beginning_of_day

Returns a new Time representing the start of the day (0:00)

Returns a new Time representing the start of the month (1st of the month, 0:00)

Returns a new Time representing the "start" of this week (Monday, 0:00)

Returns a new Time representing the start of the year (1st of january, 0:00)

Returns a new Time where one or more of the elements have been changed according to the options parameter. The time options (hour, minute, sec, usec) reset cascadingly, so if only the hour is passed, then minute, sec, and usec is set to 0. If the hour and

 minute is passed, then sec and usec is set to 0.
in(seconds)

Alias for since

Returns true only if day of time is included in the range (stime..etime). Only year days are checked.

Short-hand for months_ago(1)

Short-hand for months_ago(1)

midnight()

Alias for beginning_of_day

monday()

Alias for beginning_of_week

Returns a new Time representing the time a number of specified months ago.

Short-hand for months_since(1)

Returns a new Time representing the start of the given day in next week (default is Monday).

Short-hand for months_since(1)

Returns a new Time representing the time a number of seconds since the instance time. Do not use this method in combination with x.months, use months_since instead!

start_of_day()

Alias for beginning_of_day

Convert a Time to a Date. Time is a superset of Date. It is the year, month and day that are carried over.

Rrturns a new time at end of day

to_s( fmt = nil )

Alias for stamp

Returns a new time at start of day

To be able to keep Dates and Times interchangeable on conversions.

Convenience method which returns a new Time representing the time 1 day since the instance time

Returns a new Time representing the time a number of specified years ago.

Convenience method which returns a new Time representing the time 1 day ago

[Validate]