Fixed bug in Date.calculate_mday

master
Dirk Grambow 2009-11-17 20:17:31 +01:00
parent 49c9445ab6
commit 04370c1fed
2 changed files with 3 additions and 1 deletions

View File

@ -397,7 +397,7 @@ class Date
days = MONTH_LENGTHS[month-1]
days = 29 if month == 1 and Date.civil(year,1,1).leap?
days = 29 if month == 2 and Date.civil(year,1,1).leap?
return days - ((Date.civil(year, month, days).wday - wday + 7) % 7)
end

View File

@ -37,6 +37,8 @@ class DateTests < Test::Unit::TestCase
assert_equal 21, Date.calculate_mday(2008, 1, :third, 1)
assert_equal 1, Date.calculate_mday(2007, 1, :first, 1)
assert_equal 2, Date.calculate_mday(2007, 3, :first, :friday)
assert_equal 30, Date.calculate_mday(2012, 1, :last, 1)
assert_equal 29, Date.calculate_mday(2016, 2, :last, 1)
end
def test_mday_allows_integers_or_symbols