mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed Time#end_of_quarter to not blow up on May 31st [#313 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
parent
2d27b82d4c
commit
79f55de9c5
2 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue