aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb2
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb11
3 files changed, 14 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 27639c38a3..a53e518b3f 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing]
+
* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing]
* TimeWithZone time conversions don't need to be wrapped in TimeOrDateTime, because TZInfo does this internally [Geoff Buesing]
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 6566c1c385..43b102db2e 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -206,7 +206,7 @@ module ActiveSupport
end
def marshal_load(variables)
- initialize(variables[0], ::TimeZone[variables[1]], variables[2])
+ initialize(variables[0], ::Time.send!(:get_zone, variables[1]), variables[2])
end
# Ensure proxy class responds to all methods that underlying time instance responds to
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index f20484666e..a1776117df 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -312,6 +312,17 @@ uses_tzinfo 'TimeWithZoneTest' do
assert_equal Time.utc(1999, 12, 31, 19), mtime.time
end
end
+
+ def test_marshal_dump_and_load_with_tzinfo_identifier
+ silence_warnings do # silence warnings raised by tzinfo gem
+ twz = ActiveSupport::TimeWithZone.new(@utc, TZInfo::Timezone.get('America/New_York'))
+ marshal_str = Marshal.dump(twz)
+ mtime = Marshal.load(marshal_str)
+ assert_equal Time.utc(2000, 1, 1, 0), mtime.utc
+ assert_equal 'America/New_York', mtime.time_zone.name
+ assert_equal Time.utc(1999, 12, 31, 19), mtime.time
+ end
+ end
def test_method_missing_with_non_time_return_value
silence_warnings do # silence warnings raised by tzinfo gem