Skip to content
Browse files

config.time_zone and TimeWithZone#marshal_load accept tzinfo/Olson id…

…entifiers

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9108 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 59183ee commit c62db052a0c188c405ad97abec9dd2cec2b9b1d8 @gbuesing gbuesing committed Mar 28, 2008
View
2 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]
View
2 activesupport/lib/active_support/time_with_zone.rb
@@ -206,7 +206,7 @@ def marshal_dump
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
View
11 activesupport/test/core_ext/time_with_zone_test.rb
@@ -312,6 +312,17 @@ def test_marshal_dump_and_load
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
View
2 railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* config.time_zone accepts TZInfo::Timezone identifiers as well as Rails TimeZone identifiers [Geoff Buesing]
+
* Rails::Initializer#initialize_time_zone raises an error if value assigned to config.time_zone is not recognized. Rake time zone tasks only require ActiveSupport instead of entire environment [Geoff Buesing]
* Stop adding the antiquated test/mocks/* directories and only add them to the path if they're still there for legacy reasons [DHH]
View
2 railties/lib/initializer.rb
@@ -353,7 +353,7 @@ def initialize_temporary_session_directory
# If assigned value cannot be matched to a TimeZone, an exception will be raised.
def initialize_time_zone
if configuration.time_zone
- zone_default = TimeZone[configuration.time_zone]
+ zone_default = Time.send!(:get_zone, configuration.time_zone)
unless zone_default
raise "Value assigned to config.time_zone not recognized. Run `rake -D time` for a list of tasks for finding appropriate time zone names."
end

0 comments on commit c62db05

Please sign in to comment.
Something went wrong with that request. Please try again.