[DUG] Detecting public holidays

Bevan Edwards bevan at achieve.co.nz
Tue Dec 2 14:30:24 NZDT 2014


Hi John,

For this I created a table (but you could also use a list of objects) 
with all of the public holidays and the associated rules. Then I simply 
scan through the list, calculate when the public holiday is, and compare 
it to the date range in question.

The rules included things like "nth day of week" (eg. First Monday in 
June is Queen's Birthday), specific day/month adjusted for weekends (eg. 
25/12, 26/12, 01/01, 02/01, 06/02, 25/04), and specific day of month 
adjusted to the closest of a given day of the week (eg. Auckland 
Anniversary - which is the closest Monday to 29 January, which isn't 
necessarily the last Monday in January).

Easter was the tricky one, but I found a reliable function on the 
internet for determining which day Easter Sunday is, then you just need 
to adjust for Good Friday and Easter Monday.


I hope that helps!

Regards,

Bevan


On 2/12/2014 2:22 p.m., John C wrote:
>
> Hi all
>
> I'd like to detect whether a certain date range includes a public 
> holiday and if so what date and name.
>
> I had a look on the Internet but only found something at 
> https://pear.php.net/package/Date_Holidays which does not include NZ 
> holidays.
>
> Any other ideas?
>
> (using PHP)
>
> Thanks
>
> John C
>
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20141202/b7e97a2c/attachment.html 


More information about the Delphi mailing list