diff options
author | gbuesing <gbuesing@gmail.com> | 2008-05-08 22:48:47 -0500 |
---|---|---|
committer | gbuesing <gbuesing@gmail.com> | 2008-05-08 22:48:47 -0500 |
commit | 66728087d0eb99a524498e8f24725dae6073edd6 (patch) | |
tree | e8675936450de56cc4603d9057668cc365ae7113 /activesupport/lib | |
parent | 79e44a5ee484f977c2cad8a4cffe882b816340a1 (diff) | |
download | rails-66728087d0eb99a524498e8f24725dae6073edd6.tar.gz rails-66728087d0eb99a524498e8f24725dae6073edd6.tar.bz2 rails-66728087d0eb99a524498e8f24725dae6073edd6.zip |
Adding Date.current, which returns Time.zone.today if config.time_zone is set; otherwise returns Date.today. ActionView date_helper uses Date.current to determine locale-appropriate default
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/calculations.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index 183471706b..1e2dbf118e 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -25,6 +25,11 @@ module ActiveSupport #:nodoc: def tomorrow ::Date.today.tomorrow end + + # Returns Time.zone.today when config.time_zone is set, otherwise just returns Date.today. + def current + ::Time.zone_default ? ::Time.zone.today : ::Date.today + end end # Converts Date to a Time (or DateTime if necessary) with the time portion set to the beginning of the day (0:00) |