National Holidays

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

National Holidays

Post by onion2k »

I'm writing a calendar system at the moment, and one small aspect of it is to highlight dates that are national holidays. This presents a bit of a challenge. Fortunately, being in the UK, I can work out most of them programmatically, but the government here has had a bit of fun the last few years moving them temporarily for special occasions (the Queen's Golden Jubilee for example). I imagine the same sort of thing happens in other countries too.

This leaves me with a few options.
  • Code a system to calculate them and ignore the fact they might be wrong occasionally.
  • Code the next 5 years worth into the database, add an admin option to add/remove/change them.
  • A combination of the two options above.
  • Write a web service that runs on my site that feeds holiday dates, and make the application grab them every week so that I can change them remotely.
Or something else I've not thought of. It seems something obvious for a web service to provide but I can't find anyone offering it so I'm wondering if I've missed something.

Thoughts?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Apple offers webcal calendars you could subscribe to:

http://www.apple.com/macosx/features/ical/library/

UK holidays: webcal://ical.mac.com/ical/UK32Holidays.ics

Then just dump them into a database and make them editable. Just remember to keep the original date in a field (timestamp?) so you don't re-add edited events.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Interesting. Quite a nice format there. Only problems with using Apple's feed is that they might get rid of it one day, and I can't add things to it (eg 'New IJ Release') in the same way I could if I had my own. It's food for thought though.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I like all the options you've thought up. Something that came to my mind was writing a plug-in interface so that someone could simply inject special events and such into the calendar by those methods or their own methods.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I'm only suggesting you seed it with apple's calendar, then you must manage it yourself. You could use a calendar app like Sunbird to download the calendar, then save it in another format (xml maybe?) directly on the server. That way you could manage the calendar with a calendar app, parsing the XML into the database whenever the md5() of the file changes.

Then if the XML on the server changes (by way of a PHP script or another instance of Sunbird) everything will stay in sync, since Sunbird is built to download a fresh copy of your calendar from the server before making edits.
Post Reply