Skip to content

Commit

Permalink
fix qld labour day and queens birthday, fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiculescu committed Oct 14, 2013
1 parent 3b139ee commit 885d7e2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ To make changes to any of the definitions, edit the YAML files only.

Tests are also added at the end of the YAML files. Please add tests, it makes the pull requests go around.

After you're satisfied with the YAML file, edit the index.yaml file, run rake defs:build_all and rake defs:manifest, which will generate the ruby files that make up the actual code as well as the tests.
After you're satisfied with the YAML file, edit the index.yaml file, run `rake defs:build_all` and `rake defs:manifest`, which will generate the ruby files that make up the actual code as well as the tests.

It is also very appreciated if documentation is attached to the pull request, a simple wikipedia post referencing the change would suffice.

Expand Down
39 changes: 35 additions & 4 deletions data/au.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ months:
5:
- name: Labour Day
regions: [au_qld]
week: 1
wday: 1
function: qld_labour_day_may(year)
- name: May Day
regions: [au_nt]
week: 1
Expand All @@ -62,7 +61,7 @@ months:
week: 1
wday: 1
- name: Queen's Birthday
regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_qld, au_vic]
regions: [au_act, au_nsw, au_sa, au_qld, au_tas, au_nt, au_vic]
week: 2
wday: 1
- name: Queensland Day
Expand All @@ -79,13 +78,38 @@ months:
regions: [au_act, au_nsw, au_sa]
week: 1
wday: 1
- name: Labour Day
regions: [au_qld]
function: qld_labour_day_october(year)
- name: Queen's Birthday
regions: [au_qld]
function: qld_queens_bday_october(year)
12:
- name: Christmas Day
regions: [au]
mday: 25
- name: Boxing Day
regions: [au]
mday: 26
methods:
qld_queens_bday_october: |
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
# celebrated twice in 2012
def self.qld_queens_bday_october(year)
year == 2012 ? 1 : nil
end
qld_labour_day_may: |
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
# changed from may to october after 2012
def self.qld_labour_day_may(year)
year <= 2012 ? Date.calculate_mday(year, 5, 1, 1) : nil
end
qld_labour_day_october: |
# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
# changed from may to october after 2012
def self.qld_labour_day_october(year)
year <= 2012 ? nil : Date.calculate_mday(year, 10, 1, 1)
end
tests: |
{Date.civil(2007,1,1) => 'New Year\'s Day',
Date.civil(2007,1,26) => 'Australia Day',
Expand Down Expand Up @@ -113,4 +137,11 @@ tests: |
assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]
assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]
assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]
assert_equal 'Labour Day', Date.civil(2013,10,7).holidays(:au_qld)[0][:name]
assert_equal 'Labour Day', Date.civil(2012,5,7).holidays(:au_qld)[0][:name]
assert_equal "Queen's Birthday", Date.civil(2012,6,11).holidays(:au_qld)[0][:name]
assert_equal "Queen's Birthday", Date.civil(2012,10,1).holidays(:au_qld)[0][:name]
assert_equal "Queen's Birthday", Date.civil(2013,6,10).holidays(:au_qld)[0][:name]
31 changes: 27 additions & 4 deletions lib/holidays/au.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Holidays
# All the definitions are available at https://github.com/alexdunae/holidays
module AU # :nodoc:
def self.defined_regions
[:au, :au_tas, :au_wa, :au_vic, :au_qld, :au_nt, :au_act, :au_nsw, :au_sa, :au_qld_brisbane]
[:au, :au_nsw, :au_tas, :au_wa, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_qld_brisbane]
end

def self.holidays_by_month
Expand All @@ -29,19 +29,42 @@ def self.holidays_by_month
{:wday => 1, :week => 2, :name => "Eight Hours Day", :regions => [:au_tas]},
{:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic]}],
4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]}],
5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld]},
5 => [{:function => lambda { |year| Holidays.qld_labour_day_may(year) }, :function_id => "qld_labour_day_may(year)", :name => "Labour Day", :regions => [:au_qld]},
{:wday => 1, :week => 1, :name => "May Day", :regions => [:au_nt]}],
6 => [{:wday => 1, :week => 1, :name => "Foundation Day", :regions => [:au_wa]},
{:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_tas, :au_nt, :au_qld, :au_vic]},
{:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_qld, :au_tas, :au_nt, :au_vic]},
{:mday => 6, :type => :informal, :name => "Queensland Day", :regions => [:au_qld]}],
8 => [{:wday => 3, :week => -3, :name => "Ekka", :regions => [:au_qld_brisbane]}],
10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]}],
10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]},
{:function => lambda { |year| Holidays.qld_labour_day_october(year) }, :function_id => "qld_labour_day_october(year)", :name => "Labour Day", :regions => [:au_qld]},
{:function => lambda { |year| Holidays.qld_queens_bday_october(year) }, :function_id => "qld_queens_bday_october(year)", :name => "Queen's Birthday", :regions => [:au_qld]}],
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:au]},
{:mday => 26, :name => "Boxing Day", :regions => [:au]}]
}
end
end

# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
# celebrated twice in 2012
def self.qld_queens_bday_october(year)
year == 2012 ? 1 : nil
end


# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
# changed from may to october after 2012
def self.qld_labour_day_may(year)
year <= 2012 ? Date.calculate_mday(year, 5, 1, 1) : nil
end


# http://www.justice.qld.gov.au/fair-and-safe-work/industrial-relations/public-holidays/dates
# changed from may to october after 2012
def self.qld_labour_day_october(year)
year <= 2012 ? nil : Date.calculate_mday(year, 10, 1, 1)
end



end

Expand Down
10 changes: 10 additions & 0 deletions test/defs/test_defs_au.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ def test_au
assert_equal 'Labour Day', Date.civil(2007,3,12).holidays(:au_vic)[0][:name]
assert_equal 'Labour Day', Date.civil(2007,5,7).holidays(:au_qld)[0][:name]

assert_equal 'Easter Sunday', Date.civil(2007,4,8).holidays(:au_nsw)[0][:name]

assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]

assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]

assert_equal 'Labour Day', Date.civil(2013,10,7).holidays(:au_qld)[0][:name]
assert_equal 'Labour Day', Date.civil(2012,5,7).holidays(:au_qld)[0][:name]

assert_equal "Queen's Birthday", Date.civil(2012,6,11).holidays(:au_qld)[0][:name]
assert_equal "Queen's Birthday", Date.civil(2012,10,1).holidays(:au_qld)[0][:name]
assert_equal "Queen's Birthday", Date.civil(2013,6,10).holidays(:au_qld)[0][:name]

end
end

0 comments on commit 885d7e2

Please sign in to comment.