holidays / holidays

A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading custom holidays clears all the provided definitions?

i2chris opened this issue · comments

Hi,

Loading custom holidays like this clears all the definition files provided within the gem. is this the expected behaviour? From the readme I was given the impression I could load extra dates without it having any effect on the in-build ones

Holidays.load_custom(Rails.root.join("config", "custom_holidays.yml"))
from = Date.parse "24th Dec 2019"
to = Date.parse "01 Jan 2020"
holidays = Holidays.between(from, to, :gb, :observed)
# => []

config/custom_holidays.yml

months:
  9:
  - name: The Queen's Funeral
    regions: [gb]
    mday: 19
    year_ranges:
      limited: [2022

This works fine

[{:date=>Wed, 25 Dec 2019, :name=>"Christmas Day", :regions=>[:gb]}, {:date=>Thu, 26 Dec 2019, :name=>"Boxing Day", :regions=>[:gb]}, {:date=>Wed, 01 Jan 2020, :name=>"New Year's Day", :regions=>[:gb]}]

Thanks

Hi,
I had exactly the same issue, how did you resolved it on your side ?

Here I fixed it by creating a new region like :

months:
  9:
  - name: The Queen's Funeral
    regions: [custom]
    mday: 19
    year_ranges:
      limited: [2022

And then call it
Holidays.between(from, to, %i[gb custom], :observed)