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

Changeset 9041

Show
Ignore:
Timestamp:
03/17/08 02:54:23 (4 months ago)
Author:
gbuesing
Message:

TimeWithZone responds to Ruby 1.9 weekday-named query methods

Files:

Legend:

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

    r9040 r9041  
    11*SVN* 
     2 
     3* TimeWithZone responds to Ruby 1.9 weekday-named query methods [Geoff Buesing] 
    24 
    35* TimeWithZone caches TZInfo::TimezonePeriod used for time conversion so that it can be reused, and enforces DST rules correctly when instance is created from a local time [Geoff Buesing] 
  • trunk/activesupport/lib/active_support/time_with_zone.rb

    r9040 r9041  
    154154    alias_method :month, :mon 
    155155     
     156    %w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name| 
     157      define_method(name) do 
     158        time.__send__(name) 
     159      end 
     160    end unless RUBY_VERSION < '1.9' 
     161     
    156162    def to_a 
    157163      time.to_a[0, 8].push(dst?, zone) 
  • trunk/activesupport/test/core_ext/time_with_zone_test.rb

    r9040 r9041  
    281281      assert_equal true, twz.dst? 
    282282      assert_equal 'EDT', twz.zone 
     283    end 
     284     
     285    def test_ruby_19_weekday_name_query_methods 
     286      ruby_19_or_greater = RUBY_VERSION >= '1.9' 
     287      %w(sunday? monday? tuesday? wednesday? thursday? friday? saturday?).each do |name| 
     288        assert_equal ruby_19_or_greater, @twz.respond_to?(name) 
     289      end 
    283290    end 
    284291  end