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

Changeset 8198

Show
Ignore:
Timestamp:
11/24/07 03:57:11 (11 months ago)
Author:
gbuesing
Message:

Change Time and DateTime #end_of_month to return last second of month instead of beginning of last day of month. Closes #10200

Files:

Legend:

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

    r8137 r8198  
    11*SVN* 
     2 
     3* Change Time and DateTime #end_of_month to return last second of month instead of beginning of last day of month. Closes #10200 [Geoff Buesing] 
    24 
    35* Speedup String#blank?  [Jeremy Kemper, Koz] 
  • trunk/activesupport/lib/active_support/core_ext/date/calculations.rb

    r7868 r8198  
    158158        def end_of_month 
    159159          last_day = ::Time.days_in_month( self.month, self.year ) 
    160           self.acts_like?(:time) ? change(:day => last_day,:hour => 0, :min => 0, :sec => 0) : change(:day => last_day) 
     160          self.acts_like?(:time) ? change(:day => last_day, :hour => 23, :min => 59, :sec => 59) : change(:day => last_day) 
    161161        end 
    162162        alias :at_end_of_month :end_of_month 
  • trunk/activesupport/lib/active_support/core_ext/time/calculations.rb

    r8076 r8198  
    178178          #self - ((self.mday-1).days + self.seconds_since_midnight) 
    179179          last_day = ::Time.days_in_month( self.month, self.year ) 
    180           change(:day => last_day,:hour => 0, :min => 0, :sec => 0, :usec => 0) 
     180          change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 0) 
    181181        end 
    182182        alias :at_end_of_month :end_of_month 
  • trunk/activesupport/test/core_ext/date_time_ext_test.rb

    r8076 r8198  
    7979 
    8080  def test_end_of_month 
    81     assert_equal DateTime.civil(2005,3,31,0,0,0), DateTime.civil(2005,3,20,10,10,10).end_of_month 
    82     assert_equal DateTime.civil(2005,2,28,0,0,0), DateTime.civil(2005,2,20,10,10,10).end_of_month 
    83     assert_equal DateTime.civil(2005,4,30,0,0,0), DateTime.civil(2005,4,20,10,10,10).end_of_month 
    84  
     81    assert_equal DateTime.civil(2005,3,31,23,59,59), DateTime.civil(2005,3,20,10,10,10).end_of_month 
     82    assert_equal DateTime.civil(2005,2,28,23,59,59), DateTime.civil(2005,2,20,10,10,10).end_of_month 
     83    assert_equal DateTime.civil(2005,4,30,23,59,59), DateTime.civil(2005,4,20,10,10,10).end_of_month 
    8584  end 
    8685 
  • trunk/activesupport/test/core_ext/time_ext_test.rb

    r8076 r8198  
    8585 
    8686  def test_end_of_month 
    87     assert_equal Time.local(2005,3,31,0,0,0), Time.local(2005,3,20,10,10,10).end_of_month 
    88     assert_equal Time.local(2005,2,28,0,0,0), Time.local(2005,2,20,10,10,10).end_of_month 
    89     assert_equal Time.local(2005,4,30,0,0,0), Time.local(2005,4,20,10,10,10).end_of_month 
    90  
     87    assert_equal Time.local(2005,3,31,23,59,59), Time.local(2005,3,20,10,10,10).end_of_month 
     88    assert_equal Time.local(2005,2,28,23,59,59), Time.local(2005,2,20,10,10,10).end_of_month 
     89    assert_equal Time.local(2005,4,30,23,59,59), Time.local(2005,4,20,10,10,10).end_of_month 
    9190  end 
    9291