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

Changeset 8885

Show
Ignore:
Timestamp:
02/16/08 23:39:40 (8 months ago)
Author:
gbuesing
Message:

Time.=== returns true for TimeWithZone instances

Files:

Legend:

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

    r8884 r8885  
    11*SVN* 
     2 
     3* Time.=== returns true for TimeWithZone instances [Geoff Buesing] 
    24 
    35* TimeWithZone #+ and #- behave consistently with numeric arguments regardless of whether wrapped time is a Time or DateTime; consistenty answers false to #acts_like?(:date) [Geoff Buesing] 
  • trunk/activesupport/lib/active_support/core_ext/time/calculations.rb

    r8730 r8885  
    2525 
    2626        module ClassMethods 
     27          # Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances 
     28          def ===(other) 
     29            other.is_a?(::Time) 
     30          end 
     31           
    2732          # Return the number of days in the given month.  
    2833          # If no year is specified, it will use the current year.  
  • trunk/activesupport/test/core_ext/time_ext_test.rb

    r8806 r8885  
    469469  end 
    470470 
     471  def test_case_equality 
     472    assert Time === Time.utc(2000) 
     473    assert Time === ActiveSupport::TimeWithZone.new(Time.utc(2000), TimeZone['UTC']) 
     474    assert_equal false, Time === DateTime.civil(2000) 
     475  end 
     476 
    471477  protected 
    472478    def with_env_tz(new_tz = 'US/Eastern')