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

ago at_beginning_of_day at_beginning_of_month at_beginning_of_week at_beginning_of_year at_midnight beginning_of_day beginning_of_month beginning_of_week beginning_of_year change days_extrema elapse from_string in in_day_range? last_month last_year midnight monday months_ago months_since next_month next_week next_year seconds_since_midnight since stamp stamp start_of_day to_date to_end_of_day to_s to_start_of_day to_time tomorrow years_ago years_since yesterday

### 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

days_extrema(time1, time2=nil)

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.

elapse() {|| ...}

Tracks the elapse time of a code block.

      Time.elapse { sleep 1 }  #=> 0.999188899993896

from_string(string, options={})
stamp(*args)

### Public Instance methods

ago(seconds)

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

beginning_of_day()

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

beginning_of_month()

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

beginning_of_week()

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

beginning_of_year()

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

change(options)

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

in_day_range?(stime=ZERO, etime=NEVER)

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

last_month()

Short-hand for months_ago(1)

last_year()

Short-hand for months_ago(1)

midnight()

Alias for beginning_of_day

monday()

Alias for beginning_of_week

months_ago(months)

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

months_since(months)
next_month()

Short-hand for months_since(1)

next_week(day = :monday)

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

next_year()

Short-hand for months_since(1)

seconds_since_midnight()

Seconds since midnight: Time.now.seconds_since_midnight

since(seconds)

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!

stamp( fmt = nil )
start_of_day()

Alias for beginning_of_day

to_date()

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

to_end_of_day()

Rrturns a new time at end of day

to_s( fmt = nil )

Alias for stamp

to_start_of_day()

Returns a new time at start of day

to_time()

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

tomorrow()

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

years_ago(years)

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

years_since(years)
yesterday()

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

[Validate]