diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-03-03 17:56:51 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-03-03 17:56:51 -0300 |
commit | 33ae6344834fdf71b93e0b6db899b58e017a7655 (patch) | |
tree | 90fc2acbd349f3d637ea70ade13eaf6bb84a03a1 /activesupport/lib/active_support | |
parent | 8a74190121345083ebef1d81bf0c0129b40b33e9 (diff) | |
parent | 2cc2fa3633edd96773023c6b09d07c7b9d9b841d (diff) | |
download | rails-33ae6344834fdf71b93e0b6db899b58e017a7655.tar.gz rails-33ae6344834fdf71b93e0b6db899b58e017a7655.tar.bz2 rails-33ae6344834fdf71b93e0b6db899b58e017a7655.zip |
Merge pull request #18777 from yasyf/issue_15209
Take DST into account when locating TimeZone from Numeric
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index da39f0d245..ab6a78052c 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -239,7 +239,7 @@ module ActiveSupport end when Numeric, ActiveSupport::Duration arg *= 3600 if arg.abs <= 13 - all.find { |z| z.utc_offset == arg.to_i } + all.find { |z| z.utc_total_offset == arg.to_i } else raise ArgumentError, "invalid argument to TimeZone[]: #{arg.inspect}" end @@ -285,6 +285,12 @@ module ActiveSupport end end + # Returns the offset of this time zone from UTC in seconds, + # taking DST into account. + def utc_total_offset + tzinfo.current_period.utc_total_offset if tzinfo + end + # Returns the offset of this time zone as a formatted string, of the # format "+HH:MM". def formatted_offset(colon=true, alternate_utc_string = nil) |