Using load_custom overrides all other holiday definitions #251
Description
Hi,
Firstly apologies if I'm somehow using the library incorrectly, but I'm seeing very weird behaviour when I try to add in some extra holidays by using load_custom().
If I use Holidays.between(Date.today, Date.today + 1.years, :au_vic) to return the holidays for the next year for Victoria, Australia I get a nice list of holidays:
irb(main):002:0> Holidays.between(Date.today, Date.today + 1.years, :au_vic)
=> [{:date=>Sun, 25 Dec 2016, :name=>"Christmas Day", :regions=>[:au, :au_qld, :au_nsw, :au_act, :au_tas, :au_wa]}, {:date=>Mon, 26 Dec 2016, :name=>"Boxing Day", :regions=>[:au, :au_nsw, :au_vic, :au_qld, :au_act, :au_wa]}, {:date=>Tue, 27 Dec 2016, :name=>"Christmas Day", :regions=>[:au_vic, :au_nt]}, {:date=>Sun, 01 Jan 2017, :name=>"New Year's Day", :regions=>[:au]}, {:date=>Thu, 26 Jan 2017, :name=>"Australia Day", :regions=>[:au]}, {:date=>Mon, 13 Mar 2017, :name=>"Labour Day", :regions=>[:au_vic]}, {:date=>Fri, 14 Apr 2017, :name=>"Good Friday", :regions=>[:au]}, {:date=>Sat, 15 Apr 2017, :name=>"Easter Saturday", :regions=>[:au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa]}, {:date=>Sun, 16 Apr 2017, :name=>"Easter Sunday", :regions=>[:au_nsw, :au_vic]}, {:date=>Mon, 17 Apr 2017, :name=>"Easter Monday", :regions=>[:au]}, {:date=>Tue, 25 Apr 2017, :name=>"ANZAC Day", :regions=>[:au]}, {:date=>Tue, 25 Apr 2017, :name=>"ANZAC Day", :regions=>[:au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_tas]}, {:date=>Mon, 12 Jun 2017, :name=>"Queen's Birthday", :regions=>[:au_act, :au_nsw, :au_sa, :au_tas, :au_nt, :au_vic]}]
That unfortunately is slightly wrong because the definition for the Friday before the AFL Grand Final (don't ask!) is incorrect. Strangely the test for that holiday has a different year to the one in the actual rule, but as I actually need the 2017 holiday anyway, that's not a big deal.
After reading the docs, I created a local yaml definition file for that holiday which parses and loads successfully:
months:
10:
- name: Fridays before the AFL Grand Final
regions: [au_vic]
function: afl_grand_finals(year)
methods:
afl_grand_finals:
arguments: year
source: |
case year
when 2015
Date.civil(2015, 10, 2)
when 2016
Date.civil(2016, 9, 30)
when 2017
Date.civil(2017, 9, 29)
end
But if I try to use this definition:
irb(main):002:0> Holidays.load_custom('config/holidays.yml')
=> {10=>[{:name=>"Fridays before the AFL Grand Final", :regions=>[:au_vic], :function=>"afl_grand_finals(year)", :function_arguments=>[:year]}]}
irb(main):002:0> Holidays.between(Date.today, Date.today + 1.years, :au_vic)
=> [{:date=>Fri, 29 Sep 2017, :name=>"Fridays before the AFL Grand Final", :regions=>[:au_vic]}]
my new holiday is the only one returned. This doesn't seem to be expected behaviour!
Any clues would be much appreciated. I have tried naming my definition both "afl_grand_final" (which is a clash for an existing rule in the au definitions) and "afl_grand_finals" but neither seems to work.
Thanks for your help!