azuyalabs / yasumi

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

Multiple countries / compare? #236

Closed websecureNL closed 3 years ago

websecureNL commented 3 years ago

For our project we need the holidays for a certain period (between function) of 2 countries (origin and destination). We thought of 2 ways to get this done. 1) To be able to create a yasumi object for 2 countries 2) To make 2 separate objects and compare/merge them

Can you tell me of 1 is possible? If not, option 2 could be possible but we do not have a unique field in the object to compare. If you have any ideas on how to do this different I would be very pleased to hear so.

stelgenhof commented 3 years ago

Thank you very much for your question. Option 1 is not possible as each instance created by the Yasumi main class is a single Holiday Provider (i.e. country or subdivision).

You could write your own Factory Method to do that, however I think option 2 is the best choice. I am not familiar with your particular use case, however with option 2 you need to consider dealing with holidays from different providers happening on the same day (e.g. New Years Day).

The HolidayProvider class is iterable so you can easily create a filter or map function that processes the two instances.

github-actions[bot] commented 3 years 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.