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

Public Instance methods

Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension 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_end_of_month()

Alias for end_of_month

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.

Returns a new Time representing the end of the month (last day of the month, 0:00)

in(seconds)

Alias for since

Short-hand for months_ago(1)

Short-hand for years_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 years_since(1)

Seconds since midnight: Time.now.seconds_since_midnight

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

the Numeric extension. Do not use this method in combination with x.months, use months_since instead!

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]