Changeset 8198
- Timestamp:
- 11/24/07 03:57:11 (11 months ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/date/calculations.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/time/calculations.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/date_time_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/time_ext_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r8137 r8198 1 1 *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] 2 4 3 5 * Speedup String#blank? [Jeremy Kemper, Koz] trunk/activesupport/lib/active_support/core_ext/date/calculations.rb
r7868 r8198 158 158 def end_of_month 159 159 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) 161 161 end 162 162 alias :at_end_of_month :end_of_month trunk/activesupport/lib/active_support/core_ext/time/calculations.rb
r8076 r8198 178 178 #self - ((self.mday-1).days + self.seconds_since_midnight) 179 179 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) 181 181 end 182 182 alias :at_end_of_month :end_of_month trunk/activesupport/test/core_ext/date_time_ext_test.rb
r8076 r8198 79 79 80 80 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 85 84 end 86 85 trunk/activesupport/test/core_ext/time_ext_test.rb
r8076 r8198 85 85 86 86 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 91 90 end 92 91