Holidays with identical names in the same region are merged into the same entry
brenauj opened this issue · comments
Summary
Regions that have the same name for different days only have one entry for this name
Current behavior
For the bg_bg
region the Възкресение Христово. Великден
holiday has 2 entries in the YAML, but only one of them is returned by the gem.
~/gems/holidays$ make console
bundle exec rake console
irb -r rubygems -I lib -r holidays.rb
irb(main):001:0> Holidays::Factory::Definition.regions_repository.all_loaded
=> []
irb(main):002:0> Holidays.on(Date.civil(2020, 4, 6), :bg_bg)
=> [{:date=>#<Date: 2020-04-06 ((2458946j,0s,0n),+0s,2299161j)>, :name=>"Възкресение Христово. Великден", :regions=>[:bg_bg, :bg_bg]}]
irb(main):003:0> Holidays.on(Date.civil(2020, 4, 7), :bg_bg)
=> []
irb(main):004:0> Holidays::Factory::Definition.regions_repository.all_loaded
=> [:bg]
irb(main):005:0>
Expected behaviour
~/gems/holidays$ make console
bundle exec rake console
irb -r rubygems -I lib -r holidays.rb
irb(main):001:0> Holidays::Factory::Definition.regions_repository.all_loaded
=> []
irb(main):002:0> Holidays.on(Date.civil(2020, 4, 6), :bg_bg)
=> [{:date=>#<Date: 2020-04-06 ((2458946j,0s,0n),+0s,2299161j)>, :name=>"Възкресение Христово. Великден", :regions=>[:bg_bg]}]
irb(main):003:0> Holidays.on(Date.civil(2020, 4, 7), :bg_bg)
=> [{:date=>#<Date: 2020-04-07 ((2458947j,0s,0n),+0s,2299161j)>, :name=>"Възкресение Христово. Великден", :regions=>[:bg_bg]}]
irb(main):004:0> Holidays::Factory::Definition.regions_repository.all_loaded
=> [:bg]
irb(main):005:0>
Steps to reproduce
- Have a region that has two holidays with the exact same name (bg_bg).
- Have the holidays with the same function but not the same modifier.
- Load
holidays
viamake console
. - Call Holidays with a date matching the first holiday. You should receive the target holiday with region duplicated in the
regions
array. - Call Holidays with a date matching the second holiday. You should receive an empty array.
Detailed description
This specific scenario was found by testing if Holidays.between
yields the same dates on the same range for bg_en
and bg_bg
. A diff was found on Date.civil(2020, 4, 7)
being returned for bg_en
as Easter Monday
but not for bg_bg
.
For the bg_bg
region the Възкресение Христово. Великден
holiday has 2 entries in the YAML, but only one of them appears in the generated Ruby code.
From https://github.com/holidays/definitions/blob/v4.1.0/bg.yaml:
- name: Easter Sunday
regions: [bg_en]
function: orthodox_easter_julian(year)
- name: Възкресение Христово. Великден
regions: [bg_bg]
function: orthodox_easter_julian(year)
- name: Easter Monday
regions: [bg_en]
function: orthodox_easter_julian(year)
function_modifier: 1
- name: Възкресение Христово. Великден
regions: [bg_bg]
function: orthodox_easter_julian(year)
function_modifier: 1
May be related to #344.