Skip to content
This repository
Browse code

Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:reso…

…lved] (Danger)
  • Loading branch information...
commit 27117920af57761abe2a8660bb1f4c9849831d36 1 parent fe4d75b
David Heinemeier Hansson authored June 02, 2008
5  activesupport/CHANGELOG
... ...
@@ -1,3 +1,8 @@
  1
+*Edge*
  2
+
  3
+* Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger)
  4
+
  5
+
1 6
 *2.1.0 (May 31st, 2008)*
2 7
 
3 8
 * TimeZone#to_s shows offset as GMT instead of UTC, because GMT will be more familiar to end users (see time zone selects used by Windows OS, google.com and yahoo.com.) Reverts [8370] [Geoff Buesing]
2  activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -184,7 +184,7 @@ def beginning_of_quarter
184 184
 
185 185
         # Returns a new Date/DateTime representing the end of the quarter (last day of march, june, september, december; DateTime objects will have time set to 23:59:59)
186 186
         def end_of_quarter
187  
-          change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
  187
+          beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
188 188
         end
189 189
         alias :at_end_of_quarter :end_of_quarter
190 190
 
1  activesupport/test/core_ext/date_ext_test.rb
@@ -76,6 +76,7 @@ def test_end_of_quarter
76 76
     assert_equal Date.new(2008,3,31),  Date.new(2008,3,31).end_of_quarter
77 77
     assert_equal Date.new(2008,12,31), Date.new(2008,10,8).end_of_quarter
78 78
     assert_equal Date.new(2008,6,30),  Date.new(2008,4,14).end_of_quarter
  79
+    assert_equal Date.new(2008,6,30),  Date.new(2008,5,31).end_of_quarter
79 80
     assert_equal Date.new(2008,9,30),  Date.new(2008,8,21).end_of_quarter
80 81
   end
81 82
 

0 notes on commit 2711792

Please sign in to comment.
Something went wrong with that request. Please try again.