Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9108

Show
Ignore:
Timestamp:
03/28/08 04:35:48 (5 months ago)
Author:
gbuesing
Message:

config.time_zone and TimeWithZone#marshal_load accept tzinfo/Olson identifiers

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r9107 r9108  
    11*SVN* 
     2 
     3* TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing] 
    24 
    35* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing]  
  • trunk/activesupport/lib/active_support/time_with_zone.rb

    r9106 r9108  
    207207     
    208208    def marshal_load(variables) 
    209       initialize(variables[0], ::TimeZone[variables[1]], variables[2]) 
     209      initialize(variables[0], ::Time.send!(:get_zone, variables[1]), variables[2]) 
    210210    end 
    211211   
  • trunk/activesupport/test/core_ext/time_with_zone_test.rb

    r9107 r9108  
    313313      end 
    314314    end 
     315     
     316    def test_marshal_dump_and_load_with_tzinfo_identifier 
     317      silence_warnings do # silence warnings raised by tzinfo gem 
     318        twz = ActiveSupport::TimeWithZone.new(@utc, TZInfo::Timezone.get('America/New_York')) 
     319        marshal_str = Marshal.dump(twz) 
     320        mtime = Marshal.load(marshal_str) 
     321        assert_equal Time.utc(2000, 1, 1, 0), mtime.utc 
     322        assert_equal 'America/New_York', mtime.time_zone.name 
     323        assert_equal Time.utc(1999, 12, 31, 19), mtime.time 
     324      end 
     325    end 
    315326       
    316327    def test_method_missing_with_non_time_return_value 
  • trunk/railties/CHANGELOG

    r9104 r9108  
    11*SVN* 
     2 
     3* config.time_zone accepts TZInfo::Timezone identifiers as well as Rails TimeZone identifiers [Geoff Buesing] 
    24 
    35* 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] 
  • trunk/railties/lib/initializer.rb

    r9104 r9108  
    354354    def initialize_time_zone 
    355355      if configuration.time_zone 
    356         zone_default = TimeZone[configuration.time_zone] 
     356        zone_default = Time.send!(:get_zone, configuration.time_zone) 
    357357        unless zone_default 
    358358          raise "Value assigned to config.time_zone not recognized. Run `rake -D time` for a list of tasks for finding appropriate time zone names."