Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am getting both the holiday AND the substitute day #46

Open
flowt-au opened this issue Apr 23, 2022 · 4 comments
Open

I am getting both the holiday AND the substitute day #46

flowt-au opened this issue Apr 23, 2022 · 4 comments
Labels

Comments

@flowt-au
Copy link

Hi, I might be missing something.

Jan 1st, 2022 is Saturday. The rule is "01-01 and if saturday,sunday then next monday" so the holiday is actually on Jan 3rd.

However, the following code returns BOTH the Saturday AND the Monday as items 0 and 1 in the hols array and the isHoliday(hols[0].start) returns Jan 1st as being the holiday.

const holsObj = new Holidays('AU', 'NSW')
const hols = holsObj.getHolidays('2022')
const isHol = holsObj.isHoliday(hols[0].start) 

Using year 2025, where Jan 1st on Wednesday, it only returns the one date, as expected.

Is there a way to get the actual holiday applicable in that year?

Thanks for a great library,
Murray

@flowt-au flowt-au changed the title Getting both the holiday AND the substitute day I am getting both the holiday AND the substitute day Apr 23, 2022
@commenthol
Copy link
Owner

Hi,
I think the expected result depends on how public holidays are perceived.
For your example I strongly believe that the public will celebrate New Year on January 1st.
As this falls 2022 on a Saturday (where people usually have a day off) the legislative moves the day-off from a non-working to a working day.
Calendars on the Internet do the same. https://www.timeanddate.com/holidays/australia/

@flowt-au
Copy link
Author

Hi, and thanks for your quick reply.

I agree people will celebrate on Jan 1st. :-) And generally only if they normally do not work on Saturdays. In Australia, with a highly casualised workforce, Saturdays are often normal work days. And yes, it depends upon what one means by "Public Holiday".

Since the Public Holiday / Day off is, as the rules say, on Monday in 2022, it would be great to have an option that flags the "Day off" ie Monday, where the rules say that is a holiday. So for 2022/23 return both records as now, but Mon 3rd/2nd is flagged as the "day off" and in years where Jan 1st falls on a weekday, that Jan 1st would be flagged as the "day off".

The timeanddate link you sent correctly identifies the Monday as a "Day off", so a flag on the returned record that indicated that would be really helpful and I can adjust the displayed text if there are 2 records depending on how I need to use it.

I currently parse the returned records looking for "duplicates" and remove the redundant one, but since your functions are determining that anyway a boolean on the record would be simpler.

Thanks again for your work and for your consideration,
Murray

@commenthol
Copy link
Owner

Hi @flowt-au,
Now I got your point. Yes for substitute days there should be a substitute flag being set. This is missing for this particular case.
Will reopen as a bug.

@commenthol commenthol reopened this Apr 24, 2022
@commenthol commenthol added the bug label Apr 24, 2022
@flowt-au
Copy link
Author

Thanks so much! That will simplify things on my side. :-)
Go well,
Murray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants