azuyalabs / yasumi

The easy PHP Library for calculating holidays
https://www.yasumi.dev
Other
1.04k stars 152 forks source link

Ability to add custom holidays that may differ from year to year #283

Closed oranges13 closed 1 year ago

oranges13 commented 2 years ago

Hi there! This is a very useful tool and I would like to implement it on a project for my work. Our office has a few "extra" holidays for professional development during the year and currently we create these as entries in a database table every year (along with all the other holidays too, but I'm hoping we can replace that with this project).

My question is, the example for the NYSE adding goodFriday -- it seems like good friday is a thing that the code already knows about and you are just adding it into the class you are calling. But what about holidays which are completely and totally new and which may not exist in USA or otherwise? Is there an example for how to add completely arbitrary holidays which may differ year to year?

stelgenhof commented 2 years ago

Hi! My apologies for the late response as I have been occupied with some other projects lately.

If you create your own custom Holiday Provider class, you can add non existing holidays as easy as removing them :) Instead of add an existing holiday like Good Friday, add a method in your custom holiday class that adds the new, custom holiday. That's it!

Cheers! Sacha

github-actions[bot] commented 1 year ago

Since this issue has not had any activity within the last 90 days, I have marked it as stale. I will close it if no further activity occurs within the next 10 days.