diff options
author | Mark J. Titorenko <mark@titorenko.net> | 2012-05-07 12:04:51 +0100 |
---|---|---|
committer | Mark J. Titorenko <mark@titorenko.net> | 2012-05-07 12:04:51 +0100 |
commit | 8c4777f446d9e14deb077f44d31579a5a96e68ae (patch) | |
tree | 6d2ef1bca0805b97c32a9c9fdf19f47a69d2cb84 /guides | |
parent | 204a79fe61051dac19ac854f22f22ca4288162b8 (diff) | |
download | rails-8c4777f446d9e14deb077f44d31579a5a96e68ae.tar.gz rails-8c4777f446d9e14deb077f44d31579a5a96e68ae.tar.bz2 rails-8c4777f446d9e14deb077f44d31579a5a96e68ae.zip |
Added documentation for +beginning_of_hour+ and +end_of_hour+ to Active Support Core Extensions guide.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_support_core_extensions.textile | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile index e4a6e145b9..a238a84e8c 100644 --- a/guides/source/active_support_core_extensions.textile +++ b/guides/source/active_support_core_extensions.textile @@ -3064,6 +3064,28 @@ date.end_of_day # => Sun Jun 06 23:59:59 +0200 2010 +beginning_of_day+ is aliased to +at_beginning_of_day+, +midnight+, +at_midnight+. +h6. +beginning_of_hour+, +end_of_hour+ + +The method +beginning_of_hour+ returns a timestamp at the beginning of the hour (hh:00:00): + +<ruby> +date = DateTime.new(2010, 6, 7, 19, 55, 25) +date.beginning_of_hour # => Mon Jun 07 19:00:00 +0200 2010 +</ruby> + +The method +end_of_hour+ returns a timestamp at the end of the hour (hh:59:59): + +<ruby> +date = DateTime.new(2010, 6, 7, 19, 55, 25) +date.end_of_hour # => Mon Jun 07 19:59:59 +0200 2010 +</ruby> + ++beginning_of_hour+ is aliased to +at_beginning_of_hour+. + +INFO: +beginning_of_hour+ and +end_of_hour+ are implemented for +Time+ and +DateTime+ but *not* +Date+ as it does not make sense to request the beginning or end of an hour on a +Date+ instance. + +NOTE: All the following methods are defined in +active_support/core_ext/date/calculations.rb+. + h6. +ago+, +since+ The method +ago+ receives a number of seconds as argument and returns a timestamp those many seconds ago from midnight: @@ -3131,6 +3153,13 @@ since (in) On the other hand, +advance+ and +change+ are also defined and support more options, they are documented below. +The following methods are only implemented in +active_support/core_ext/date_time/calculations.rb+ as they only make sense when used with a +DateTime+ instance: + +<ruby> +beginning_of_hour (at_beginning_of_hour) +end_of_hour +</ruby> + h5. Named Datetimes h6. +DateTime.current+ @@ -3273,6 +3302,8 @@ ago since (in) beginning_of_day (midnight, at_midnight, at_beginning_of_day) end_of_day +beginning_of_hour (at_beginning_of_hour) +end_of_hour beginning_of_week (at_beginning_of_week) end_of_week (at_end_of_week) monday |