azuyalabs / yasumi

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

Add non-working day flag #231

Closed hktr92 closed 3 years ago

hktr92 commented 4 years ago

Hello.

I've developed a time tracking app back in 2017 that registers if an employee takes a period of time away from office. Because there are non-working days, we've implemented an entity that needs manual input from those data.

I've been looking for a replacement for a while, to get rid of manual input, then I found this project on Reddit. The integration in our project went flawless. Then I noticed some improvements that I could do to this project, in order to cut some lines of code when determining non-working days.

So I've forked this repository to add an $nonWorkingDay flag in Holiday, which is typed as bool $nonWorkingDay = nul and has a fallback to $type === Holiday::TYPE_OFFICIAL and added a filter class. The fallback is made in order to prevent BC, as most official holidays are non-working day (don't know about other countries). At least, this is the case in Romania, I'm don't know about other countries.

This is more like a shortcut to filter out official holidays, which from what I've read on the providers page, it might not be as reliable as it seems, so this little "hack" might do the trick.

Additionally, I've added a Dockerfile with php7.2-cli-alpine as I don't have any PHP runtime installed natively, with two helper scripts: composer.sh and php.sh. These aren't necessary to be merged with upstream, as I made these for my local development.

Don't know if the tests will pass, as I've ran composer test inside a docker container and it fails: image

Hopefully, the code works without any issues, so it could be merged asap to upstream.

stelgenhof commented 4 years ago

Thanks for the PR! This is a hot-item at the moment (working day vs non-working day) and is something I am working on at the moment as well. Let me have a look at your PR in the next few days.

hktr92 commented 4 years ago

sure, take your time. i'll be available if needed.

github-actions[bot] commented 3 years ago

This pull request has been open 60 days with no activity. Please remove the stale label or comment, or this will be closed in 10 days.