Informal Holidays in custom definition are returned even if :observed is asked
ste26054 opened this issue · comments
Hello,
I am using the Holidays gem version 6.4.0
with ruby 2.3.4
I created the following custom_region.yaml
:
---
months:
1:
- name: Informal day
regions: [custom_region]
mday: 1
type: informal
Here, I expect 2018-01-01
to be an informal holiday.
2.3.4 :001 > Holidays.load_custom("custom_region.yaml")
=> {1=>[{:name=>"Informal day", :regions=>[:custom_region], :mday=>1, :type=>"informal"}]}
2.3.4 :003 > Holidays.on(Date.new(2018,1,1), :custom_region, :informal)
=> [{:date=>Mon, 01 Jan 2018, :name=>"Informal day", :regions=>[:custom_region]}] #OK
2.3.4 :004 > Holidays.on(Date.new(2018,1,1), :custom_region, :observed)
=> [{:date=>Mon, 01 Jan 2018, :name=>"Informal day", :regions=>[:custom_region]}] # ERROR: Nothing should be returned
So it seems Informal days in custom definitions are not working, or am I missing something?
OK, I found the source of the problem. In this case, the definition should be formatted like this:
---
months:
1:
- name: Informal day
regions: [custom_region]
mday: 1
type: :informal
Note that type: :informal
line, where :informal
is explicitly passed as a symbol. I did not look into that first because all the existing definitions were using type: informal
If we do not pass a symbol, the type is passed as a string and fails the following check:
Hence all informal holidays are wrongly ignored.
A simple fix would be to correct the check above
I will try to make a pull request if I have time
Whoops! This should have been closed back in September. Sorry for the mistake, I just misunderstood what was merged and didn't follow up on this specific issue. Thanks for the PR!