Open flowt-au opened 2 years ago
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/
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
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.
Thanks so much! That will simplify things on my side. :-) Go well, Murray
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.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