Skip to content

Commit

Permalink
Updated the AS guides with some information on the difference between…
Browse files Browse the repository at this point in the history
… Date.today and Date.current.
  • Loading branch information
joshk authored and jeremy committed Feb 28, 2011
1 parent 0f8d279 commit 7112cf5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion railties/guides/source/active_support_core_extensions.textile
Expand Up @@ -2791,6 +2791,8 @@ h5. +Date.current+


Active Support defines +Date.current+ to be today in the current time zone. That's like +Date.today+, except that it honors the user time zone, if defined. It also defines +Date.yesterday+ and +Date.tomorrow+, and the instance predicates +past?+, +today?+, and +future?+, all of them relative to +Date.current+. Active Support defines +Date.current+ to be today in the current time zone. That's like +Date.today+, except that it honors the user time zone, if defined. It also defines +Date.yesterday+ and +Date.tomorrow+, and the instance predicates +past?+, +today?+, and +future?+, all of them relative to +Date.current+.


When making Date comparisons using methods which honor the user time zone, make sure to use +Date.current+ and not +Date.today+. There are cases where the user time zone might be in the future compared to the system time zone, which +Date.today+ uses by default. This means +Date.today+ may equal +Date.yesterday+.

h5. Named dates h5. Named dates


h6. +prev_year+, +next_year+ h6. +prev_year+, +next_year+
Expand Down Expand Up @@ -3105,7 +3107,7 @@ h5. Named Datetimes


h6. +DateTime.current+ h6. +DateTime.current+


Active Support defines +DateTime.current+ to be like +Time.now.to_datetime+, except that it honors the user time zone, if defined. It also defines instance predicates +past?+, and +future?+ relative to +DateTime.current+. Active Support defines +DateTime.current+ to be like +Time.now.to_datetime+, except that it honors the user time zone, if defined. It also defines +DateTime.yesterday+ and +DateTime.tomorrow+, and the instance predicates +past?+, and +future?+ relative to +DateTime.current+.


h5. Other Extensions h5. Other Extensions


Expand Down Expand Up @@ -3282,6 +3284,12 @@ t.advance(:seconds => 1)


* If +since+ or +ago+ jump to a time that can't be expressed with +Time+ a +DateTime+ object is returned instead. * If +since+ or +ago+ jump to a time that can't be expressed with +Time+ a +DateTime+ object is returned instead.


h5. +Time.current+

Active Support defines +Time.current+ to be today in the current time zone. That's like +Time.now+, except that it honors the user time zone, if defined. It also defines +Time.yesterday+ and +Time.tomorrow+, and the instance predicates +past?+, +today?+, and +future?+, all of them relative to +Time.current+.

When making Time comparisons using methods which honor the user time zone, make sure to use +Time.current+ and not +Time.now+. There are cases where the user time zone might be in the future compared to the system time zone, which +Time.today+ uses by default. This means +Time.now+ may equal +Time.yesterday+.

h4. Time Constructors h4. Time Constructors


Active Support defines +Time.current+ to be +Time.zone.now+ if there's a user time zone defined, with fallback to +Time.now+: Active Support defines +Time.current+ to be +Time.zone.now+ if there's a user time zone defined, with fallback to +Time.now+:
Expand Down

0 comments on commit 7112cf5

Please sign in to comment.