aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb8
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)