Ticket #6483: next_week_dst_compatibility.patch
| File next_week_dst_compatibility.patch, 1.7 kB (added by marclove, 2 years ago) |
|---|
-
activesupport/lib/active_support/core_ext/time/calculations.rb
old new 135 135 # Returns a new Time representing the start of the given day in next week (default is Monday). 136 136 def next_week(day = :monday) 137 137 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) 139 141 end 140 142 141 143 # Returns a new Time representing the start of the day (0:00) -
activesupport/test/core_ext/time_ext_test.rb
old new 146 146 assert_equal Time.local(2005,2,28), Time.local(2005,2,22,15,15,10).next_week 147 147 assert_equal Time.local(2005,2,29), Time.local(2005,2,22,15,15,10).next_week(:tuesday) 148 148 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) 149 151 end 150 152 151 153 def test_to_s