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

Changeset 9081

Show
Ignore:
Timestamp:
03/23/08 04:44:50 (7 months ago)
Author:
rick
Message:

Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]

Files:

Legend:

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

    r9079 r9081  
    11*SVN* 
     2 
     3* Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter.  [rick] 
    24 
    35* Ensure correct TimeWithZone#to_date [Geoff Buesing] 
  • trunk/activesupport/lib/active_support/time_with_zone.rb

    r9079 r9081  
    8181     
    8282    def to_yaml(options = {}) 
    83       time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z')) 
     83      if options.kind_of?(YAML::Emitter) 
     84        utc.to_yaml(options) 
     85      else 
     86        time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z')) 
     87      end 
    8488    end 
    8589     
  • trunk/activesupport/test/core_ext/time_with_zone_test.rb

    r9079 r9081  
    104104      silence_warnings do # silence warnings raised by tzinfo gem 
    105105        assert_equal "--- 1999-12-31 19:00:00 -05:00\n", @twz.to_yaml 
     106      end 
     107    end 
     108     
     109    def test_ruby_to_yaml 
     110      silence_warnings do 
     111        assert_equal "--- \n:twz: 2000-01-01 00:00:00 Z\n", {:twz => @twz}.to_yaml 
    106112      end 
    107113    end