diff --git a/lib/holidays.rb b/lib/holidays.rb index 7d41b69..45ca444 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -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 diff --git a/test/test_date.rb b/test/test_date.rb index 06bbea1..920fdf2 100644 --- a/test/test_date.rb +++ b/test/test_date.rb @@ -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