Module | ActiveSupport::CoreExtensions::Date::Calculations |
In: |
lib/active_support/core_ext/date/calculations.rb
|
Enables the use of time calculations within Time itself
Provides precise Date calculations for years, months, and days. The options parameter takes a hash with any of these keys: :years, :months, :weeks, :days.
Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) and then subtracts the specified number of seconds
Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00)
Returns a new ; DateTime objects will have time set to 0:00DateTime representing the start of the month (1st of the month; DateTime objects will have time set to 0:00)
Returns a new Date/DateTime representing the start of the quarter (1st of january, april, july, october; DateTime objects will have time set to 0:00)
Returns a new Date/DateTime representing the "start" of this week (i.e, Monday; DateTime objects will have time set to 0:00)
Returns a new Date/DateTime representing the start of the year (1st of january; DateTime objects will have time set to 0:00)
Returns a new Date where one or more of the elements have been changed according to the options parameter.
Examples:
Date.new(2007, 5, 12).change(:day => 1) # => Date.new(2007, 5, 1) Date.new(2007, 5, 12).change(:year => 2005, :month => 1) # => Date.new(2005, 1, 12)
Converts Date to a Time (or DateTime if necessary) with the time portion set to the end of the day (23:59:59)
Returns a new Date/DateTime representing the end of the month (last day of the month; DateTime objects will have time set to 0:00)
Returns a new Date/DateTime representing the end of the quarter (last day of march, june, september, december; DateTime objects will have time set to 23:59:59)
Returns a new Date/DateTime representing the end of this week (Sunday, DateTime objects will have time set to 23:59:59)
Returns a new Time representing the end of the year (31st of december; DateTime objects will have time set to 23:59:59)
Returns a new Date/DateTime representing the time a number of specified months ago
Returns a new Date/DateTime representing the time a number of specified months in the future
Returns a new Date/DateTime representing the start of the given day in next week (default is Monday).
Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) and then adds the specified number of seconds
Convenience method which returns a new Date/DateTime representing the time 1 day since the instance time
Returns a new Date/DateTime representing the time a number of specified years in the future