Module | ActiveSupport::CoreExtensions::Time::Calculations |
In: |
lib/active_support/core_ext/time/calculations.rb
|
Enables the use of time calculations within Time itself
COMMON_YEAR_DAYS_IN_MONTH | = | [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] |
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
Returns a new Time representing the start of the quarter (1st of january, april, july, october, 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 quarter (last day of march, june, september, december, 23:59:59)
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
Returns a new Time representing the time a number of specified months in the future
Returns a new Time representing the start of the given day in next week (default is Monday).
Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around the Numeric extension.
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 in the future