aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Brando <eduardobrando@gmail.com>2008-09-19 09:06:35 -0500
committerJoshua Peek <josh@joshpeek.com>2008-09-19 09:06:35 -0500
commit79f55de9c5e3ff1f8d9e767c5af21ba31be4cfba (patch)
tree64ec2b1a15c381dbda8f979672f883e9e12c12ce
parent2d27b82d4cf446543539ad20afcbad256d8aeff7 (diff)
downloadrails-79f55de9c5e3ff1f8d9e767c5af21ba31be4cfba.tar.gz
rails-79f55de9c5e3ff1f8d9e767c5af21ba31be4cfba.tar.bz2
rails-79f55de9c5e3ff1f8d9e767c5af21ba31be4cfba.zip
Fixed Time#end_of_quarter to not blow up on May 31st [#313 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb2
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 070f72c854..3cc6d59907 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -223,7 +223,7 @@ module ActiveSupport #:nodoc:
# Returns a new Time representing the end of the quarter (last day of march, june, september, december, 23:59:59)
def end_of_quarter
- change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
+ beginning_of_month.change(:month => [3, 6, 9, 12].detect { |m| m >= self.month }).end_of_month
end
alias :at_end_of_quarter :end_of_quarter
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 7e5540510c..8ceaedc7f4 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -117,6 +117,7 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
assert_equal Time.local(2007,3,31,23,59,59), Time.local(2007,3,31,0,0,0).end_of_quarter
assert_equal Time.local(2007,12,31,23,59,59), Time.local(2007,12,21,10,10,10).end_of_quarter
assert_equal Time.local(2007,6,30,23,59,59), Time.local(2007,4,1,0,0,0).end_of_quarter
+ assert_equal Time.local(2008,6,30,23,59,59), Time.local(2008,5,31,0,0,0).end_of_quarter
end
def test_end_of_year