Module ActiveSupport::CoreExtensions::Time::Calculations
In: lib/active_support/core_ext/time/calculations.rb

Enables the use of time calculations within Time itself

Methods

Classes and Modules

Module ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods

Constants

COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

Public Instance methods

Uses Date to provide precise Time calculations for years, months, and days. The options parameter takes a hash with any of these keys: :years, :months, :weeks, :days, :hours, :minutes, :seconds.

Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension

at_beginning_of_day()

Alias for beginning_of_day

at_beginning_of_month()

Alias for beginning_of_month

at_beginning_of_quarter()
at_beginning_of_week()

Alias for beginning_of_week

at_beginning_of_year()

Alias for beginning_of_year

at_end_of_month()

Alias for end_of_month

at_end_of_quarter()

Alias for end_of_quarter

at_end_of_week()

Alias for end_of_week

at_end_of_year()

Alias for end_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 the quarter (1st of january, april, july, october, 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.

Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared with a Time

Returns a new Time representing the end of the day, 23:59:59.999999 (.999999999 in ruby1.9)

Returns a new Time representing the end of the month (end of the last day of the month)

Returns a new Time representing the end of the quarter (end of the last day of march, june, september, december)

Returns a new Time representing the end of this week (Sunday, 23:59:59)

Returns a new Time representing the end of the year (end of the 31st of december)

Tells whether the Time object‘s time lies in the future

in(seconds)

Alias for since

midnight()

Alias for beginning_of_day

Time#- can also be used to determine the number of seconds between two Time instances. We‘re layering on additional behavior so that ActiveSupport::TimeWithZone instances are coerced into values that Time#- will recognize

monday()

Alias for beginning_of_week

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

Returns a new Time representing the time a number of specified months in the future

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 years_since(1)

Tells whether the Time object‘s time lies in the past

Short-hand for months_ago(1)

Short-hand for years_ago(1)

Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around the Numeric extension.

Tells whether the Time object‘s time is today

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

Returns a new Time representing the time a number of specified years in the future

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

[Validate]