NOTE: All the following methods are defined in +active_support/core_ext/date_time/calculations.rb+.
WARNING: +DateTime+ is not aware of DST rules and so some of these methods have edge cases when a DST change is going on. For example +seconds_since_midnight+ might not return the real amount in such a day.
h4(#calculations-datetime). Calculations
NOTE: All the following methods are defined in +active_support/core_ext/date_time/calculations.rb+.
The class +DateTime+ is a subclass of +Date+ so by loading +active_support/core_ext/date/calculations.rb+ you inherit these methods and their aliases, except that they will always return datetimes:
<ruby>
yesterday
tomorrow
beginning_of_week
end_on_week
beginning_of_week (monday, at_beginning_of_week)
end_on_week (at_end_of_week)
next_week
months_ago
months_since
beginning_of_month
end_of_month
beginning_of_month (at_beginning_of_month)
end_of_month (at_end_of_month)
prev_month
next_month
beginning_of_quarter
end_of_quarter
beginning_of_year
end_of_year
beginning_of_quarter (at_beginning_of_quarter)
end_of_quarter (at_end_of_quarter)
beginning_of_year (at_beginning_of_year)
end_of_year (at_end_of_year)
years_ago
years_since
prev_year
...
...
@@ -3086,10 +3086,10 @@ next_year
The following methods are reimplemented so you do *not* need to load +active_support/core_ext/date/calculations.rb+ for these ones:
Both +local_time+ and +utc_time+ accept up to seven positional arguments: year, month, day, hour, min, sec, usec. Year is mandatory, month and day default to 1, and the rest default to 0.
If the time to be constructed lies beyond the range supported by +Time+ in the runtime platform, usecs are discarded and a +DateTime+ object is returned instead.