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

Changeset 9079

Show
Ignore:
Timestamp:
03/22/08 18:43:36 (4 months ago)
Author:
gbuesing
Message:

Ensure correct TimeWithZone#to_date

Files:

Legend:

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

    r9071 r9079  
    11*SVN* 
     2 
     3* Ensure correct TimeWithZone#to_date [Geoff Buesing] 
    24 
    35* Make TimeWithZone work with tzinfo 0.2.x: use TZInfo::Timezone#zone_identifier alias for #abbreviation, silence warnings on tests. Raise LoadError when TZInfo version is < 0.2 by sniffing for TZInfo::TimeOrDateTime constant. Move all tzinfo-dependent TimeZone tests into uses_tzinfo block [Geoff Buesing] 
  • trunk/activesupport/lib/active_support/time_with_zone.rb

    r9071 r9079  
    140140    end 
    141141     
    142     %w(asctime day hour min mon sec usec wday yday year).each do |name| 
     142    %w(asctime day hour min mon sec usec wday yday year to_date).each do |name| 
    143143      define_method(name) do 
    144144        time.__send__(name) 
  • trunk/activesupport/test/core_ext/time_with_zone_test.rb

    r9071 r9079  
    255255      assert_equal @twz, @twz.to_time 
    256256    end 
     257 
     258    def test_to_date 
     259      silence_warnings do # silence warnings raised by tzinfo gem 
     260        # 1 sec before midnight Jan 1 EST 
     261        assert_equal Date.new(1999, 12, 31), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 4, 59, 59), TimeZone['Eastern Time (US & Canada)'] ).to_date 
     262        # midnight Jan 1 EST 
     263        assert_equal Date.new(2000,  1,  1), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 5,  0,  0), TimeZone['Eastern Time (US & Canada)'] ).to_date 
     264        # 1 sec before midnight Jan 2 EST 
     265        assert_equal Date.new(2000,  1,  1), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2, 4, 59, 59), TimeZone['Eastern Time (US & Canada)'] ).to_date 
     266        # midnight Jan 2 EST 
     267        assert_equal Date.new(2000,  1,  2), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2, 5,  0,  0), TimeZone['Eastern Time (US & Canada)'] ).to_date 
     268      end 
     269    end 
    257270     
    258271    def test_to_datetime