diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-11-05 22:29:11 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-11-05 22:29:11 +0000 |
commit | 47576a646bd99d431f4217b20b7625bdd3444171 (patch) | |
tree | 1e2912a07b1cf0458ddc090c37c67001f124b7ee /activesupport/lib/active_support/core_ext/date_time/calculations.rb | |
parent | 800b69b6adab2e2ea90b66fd2b37ed05f973b1d5 (diff) | |
download | rails-47576a646bd99d431f4217b20b7625bdd3444171.tar.gz rails-47576a646bd99d431f4217b20b7625bdd3444171.tar.bz2 rails-47576a646bd99d431f4217b20b7625bdd3444171.zip |
Cater for DST changes when converting Times to DateTimes. Closes #10068 [gbuesing]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8076 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time/calculations.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index b672ada7b9..2e85d14579 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -5,6 +5,16 @@ module ActiveSupport #:nodoc: module DateTime #:nodoc: # Enables the use of time calculations within DateTime itself module Calculations + def self.included(base) #:nodoc: + base.extend ClassMethods + end + + module ClassMethods + # DateTimes aren't aware of DST rules, so use a consistent non-DST offset when creating a DateTime with an offset in the local zone + def local_offset + ::Time.local(2007).utc_offset.to_r / 86400 + end + end # Seconds since midnight: DateTime.now.seconds_since_midnight def seconds_since_midnight |