Merge remote branch 'bjeanes/master'
This commit is contained in:
commit
b81fc99197
|
@ -66,6 +66,11 @@ months:
|
||||||
regions: [au_qld]
|
regions: [au_qld]
|
||||||
mday: 6
|
mday: 6
|
||||||
type: informal
|
type: informal
|
||||||
|
8:
|
||||||
|
- name: Ekka
|
||||||
|
regions: [au_qld_brisbane]
|
||||||
|
week: -3
|
||||||
|
wday: 3
|
||||||
10:
|
10:
|
||||||
- name: Labour Day
|
- name: Labour Day
|
||||||
regions: [au_act, au_nsw, au_sa]
|
regions: [au_act, au_nsw, au_sa]
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Holidays
|
||||||
@@holidays_by_month = {}
|
@@holidays_by_month = {}
|
||||||
@@proc_cache = {}
|
@@proc_cache = {}
|
||||||
|
|
||||||
WEEKS = {:first => 1, :second => 2, :third => 3, :fourth => 4, :fifth => 5, :last => -1}
|
WEEKS = {:first => 1, :second => 2, :third => 3, :fourth => 4, :fifth => 5, :last => -1, :second_last => -2, :third_last => -3}
|
||||||
MONTH_LENGTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
MONTH_LENGTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||||
DAY_SYMBOLS = Date::DAYNAMES.collect { |n| n.downcase.intern }
|
DAY_SYMBOLS = Date::DAYNAMES.collect { |n| n.downcase.intern }
|
||||||
|
|
||||||
|
@ -399,6 +399,6 @@ class Date
|
||||||
|
|
||||||
days = 29 if month == 2 and Date.leap?(year)
|
days = 29 if month == 2 and Date.leap?(year)
|
||||||
|
|
||||||
return days - ((Date.civil(year, month, days).wday - wday + 7) % 7)
|
return days - ((Date.civil(year, month, days).wday - wday + 7) % 7) - (7 * (week.abs - 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -11,7 +11,7 @@ module Holidays
|
||||||
#
|
#
|
||||||
# More definitions are available at http://code.dunae.ca/holidays.
|
# More definitions are available at http://code.dunae.ca/holidays.
|
||||||
module AU # :nodoc:
|
module AU # :nodoc:
|
||||||
DEFINED_REGIONS = [:au_qld, :au_nt, :au, :au_tas, :au_wa, :au_act, :au_nsw, :au_sa, :au_vic]
|
DEFINED_REGIONS = [:au_qld, :au_nt, :au, :au_tas, :au_wa, :au_act, :au_nsw, :au_sa, :au_vic, :au_qld_brisbane]
|
||||||
|
|
||||||
HOLIDAYS_BY_MONTH = {
|
HOLIDAYS_BY_MONTH = {
|
||||||
5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld]},
|
5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld]},
|
||||||
|
@ -27,6 +27,7 @@ module Holidays
|
||||||
{:mday => 26, :name => "Australia Day", :regions => [:au]}],
|
{:mday => 26, :name => "Australia Day", :regions => [:au]}],
|
||||||
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:au]},
|
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:au]},
|
||||||
{:mday => 26, :name => "Boxing Day", :regions => [:au]}],
|
{:mday => 26, :name => "Boxing Day", :regions => [:au]}],
|
||||||
|
8 => [{:wday => 3, :week => -3, :name => "Ekka", :regions => [:au_qld_brisbane]}],
|
||||||
3 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_wa]},
|
3 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_wa]},
|
||||||
{:wday => 1, :week => 2, :name => "Eight Hours Day", :regions => [:au_tas]},
|
{:wday => 1, :week => 2, :name => "Eight Hours Day", :regions => [:au_tas]},
|
||||||
{:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic]}],
|
{:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic]}],
|
||||||
|
|
|
@ -39,6 +39,18 @@ class DateTests < Test::Unit::TestCase
|
||||||
assert_equal 2, Date.calculate_mday(2007, 3, :first, :friday)
|
assert_equal 2, Date.calculate_mday(2007, 3, :first, :friday)
|
||||||
assert_equal 30, Date.calculate_mday(2012, 1, :last, 1)
|
assert_equal 30, Date.calculate_mday(2012, 1, :last, 1)
|
||||||
assert_equal 29, Date.calculate_mday(2016, 2, :last, 1)
|
assert_equal 29, Date.calculate_mday(2016, 2, :last, 1)
|
||||||
|
|
||||||
|
# From end of month
|
||||||
|
assert_equal 26, Date.calculate_mday(2009, 8, -1, :wednesday)
|
||||||
|
assert_equal 19, Date.calculate_mday(2009, 8, -2, :wednesday)
|
||||||
|
assert_equal 12, Date.calculate_mday(2009, 8, -3, :wednesday)
|
||||||
|
|
||||||
|
assert_equal 13, Date.calculate_mday(2008, 8, -3, :wednesday)
|
||||||
|
assert_equal 12, Date.calculate_mday(2009, 8, -3, :wednesday)
|
||||||
|
assert_equal 11, Date.calculate_mday(2010, 8, -3, :wednesday)
|
||||||
|
assert_equal 17, Date.calculate_mday(2011, 8, -3, :wednesday)
|
||||||
|
assert_equal 15, Date.calculate_mday(2012, 8, -3, :wednesday)
|
||||||
|
assert_equal 14, Date.calculate_mday(2013, 8, -3, :wednesday)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mday_allows_integers_or_symbols
|
def test_mday_allows_integers_or_symbols
|
||||||
|
|
Loading…
Reference in a new issue