diff options
author | gbuesing <gbuesing@gmail.com> | 2008-05-08 20:56:38 -0500 |
---|---|---|
committer | gbuesing <gbuesing@gmail.com> | 2008-05-08 20:56:38 -0500 |
commit | fb9bf16e96e2c24d4996327500d8109b5d535e2c (patch) | |
tree | 87d0b30af0901868c5604ee2a50b3a8de5807a14 /activesupport/lib/active_support | |
parent | 328fada610aa9128386bc4b372d3e0b68aede945 (diff) | |
download | rails-fb9bf16e96e2c24d4996327500d8109b5d535e2c.tar.gz rails-fb9bf16e96e2c24d4996327500d8109b5d535e2c.tar.bz2 rails-fb9bf16e96e2c24d4996327500d8109b5d535e2c.zip |
Time.zone.parse: compatibility with far future date with time zone offset in string. Eliminate creation of additional TimeWithZone instance to determine utc offset.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 2342cd182c..d597d99880 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -214,10 +214,11 @@ class TimeZone # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 def parse(str, now=now) time = Time.parse(str, now) rescue DateTime.parse(str) - unless time.is_a?(DateTime) || Date._parse(str)[:offset].nil? - time += time.in_time_zone(self).utc_offset - time.utc_offset + if Date._parse(str)[:offset].nil? + ActiveSupport::TimeWithZone.new(nil, self, time) + else + time.in_time_zone(self) end - ActiveSupport::TimeWithZone.new(nil, self, time) end # Returns an ActiveSupport::TimeWithZone instance representing the current time |