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

Changeset 5363

Show
Ignore:
Timestamp:
10/24/06 23:35:27 (2 years ago)
Author:
bitsweat
Message:

next_week respects DST changes. Closes #6483.

Files:

Legend:

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

    r5334 r5363  
    11*SVN* 
     2 
     3* next_week respects DST changes.  #6483 [marclove] 
    24 
    35* Expose methods added to Enumerable in the documentation, such as group_by. Closes #6170. [sergeykojin@gmail.com, Marcel Molina Jr.] 
  • trunk/activesupport/lib/active_support/core_ext/time/calculations.rb

    r4312 r5363  
    136136        def next_week(day = :monday) 
    137137          days_into_week = { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6} 
    138           since(1.week).beginning_of_week.since(days_into_week[day].day).change(:hour => 0) 
     138          # Adjust in case of switches to or from daylight savings time 
     139          week_from_today = self.since(1.week) + (self.since(1.week) <=> self).hour 
     140          week_from_today.beginning_of_week.since(days_into_week[day].day).change(:hour => 0) 
    139141        end 
    140142         
  • trunk/activesupport/test/core_ext/time_ext_test.rb

    r4595 r5363  
    147147    assert_equal Time.local(2005,2,29), Time.local(2005,2,22,15,15,10).next_week(:tuesday) 
    148148    assert_equal Time.local(2005,3,4), Time.local(2005,2,22,15,15,10).next_week(:friday) 
     149    assert_equal Time.local(2006,10,30), Time.local(2006,10,23,0,0,0).next_week 
     150    assert_equal Time.local(2006,11,1), Time.local(2006,10,23,0,0,0).next_week(:wednesday) 
    149151  end 
    150152