azuyalabs / yasumi

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

Custom Holiday #295

Closed sebastianpisula closed 1 year ago

sebastianpisula commented 1 year ago

I can't reopen https://github.com/azuyalabs/yasumi/issues/230 issue so I created new.

I expect that if I have holidays in Poland, and I add a new date, Yasumi::nextWorkingDay will take this into account. For example - in Poland we have holidays on December 24th, 25th, and 26th. If I add December 27th and run the script with the date 23rd, I expect that the next working day will be December 28th.

$holidays = Yasumi::create( 'Poland', 2022 ); $holidays->addHoliday( new Holiday( 'Holiday 1', [], new \DateTimeImmutable( '2022-12-27' ) ) );

var_dump( Yasumi::nextWorkingDay( 'Poland', new \DateTimeImmutable('2022-12-23') )->format( 'Y-m-d' ) );

stelgenhof commented 1 year ago

Hi @sebastianpisula Unfortunately this is maybe a shortcoming. The static nextWorkingDay method only will work with the default holiday provider. Your third line of code (var_dump... does not share the same context from the previous lines where you've add the custom holiday. Yasumi is not aware of this custom holiday, hence considering the 27th December still to be a regular day.

There is no immediate solution for this, other than making breaking API changes.

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.

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.