tags:

views:

1264

answers:

6

Is there a public/government web service that I can call to find out what the national holidays are for a given year? (For the US and/or any country in the world.)

Edit: Does anybody have a set of formulas to calculate US holidays? (C# would be my language of choice if there is a choice.)

+1  A: 

No one gives that up for free (any country in the world? Get real). The best source is Copp Clark (I'm unaffiliated). They provide all holidays for all countries broken down by financial market, currency, etc.

+1  A: 

Some parsing may be required, and it's not 100% complete, but you can use wikipedia.

Andrew Johnson
+1  A: 

For the method/assembly to figure out US Holidays, basically just figure out all the major holidays and the "formula" that they use.

For the ones that never change, like Christmas, it's easy - December 25th.

For the ones that do change somewhat, there's usually a formula - like the third Monday in February being Presidents Day. You can just have the method figure this out for a given year.

This won't work for holidays without any particular pattern (i.e., some committee decides what the date is every year) but for all the major ones there's easily discernible formulas.

This would actually be a great candidate for Test Driven Design. You will know all of the major holiday dates for a particular year, so you should be able to feed that year into the method and get the right answers.

Schnapple
+4  A: 

There's a web service at http://www.holidaywebservice.com which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code.

As for details of algorithms, you could do worse than check out the excellent Calendrical Calculations book (third edition), which is a really fascinating read for all matters calendrical, and includes sample LISP code for their calendar algorithms.

Ian Nelson
Cool service and references, but my problem is trying to find a up-to-date source of which holidays are official U.S. government holidays (as in, the feds aren't at work on those days).
CMPalmer
Interesting site, but it's so horribly designed (my eyes bled), and it doesn't have anything like isHoliday(date).
Chris S
Would you really want to call a remote service to determine if a particular date were a holiday? That sounds like the kind of method call that would be made frequently. Surely more performant to periodically make a remote call to get a list of holidays in a particular year, cache that information locally, and use it in your own local implementation of isHoliday(date).Incidentally, if your eyes are bleeding it might be prudent to take a break from posting on SO and seek medical assistance.
Ian Nelson
+2  A: 

There are online calendars you can subscribe to. For example, Google provides US Holidays:

ICAL XML HTML

Brandon
+1  A: 

There are tons of similar information that really should be provided by government web services. It would certainly save a lot of money and errors in the long run if the U.S. Government could provide information like this through web services. Heck, even having it in a downloadable, parseable format would be a big step in the right direction.

I ran across this question while looking for a way to ensure an application skipped all U.S. Federal holidays in working days calculations. The best .gov source I found is:

Operating Status Schedules from OPM

This has the data we need through 2020, but we'll have to type it into our own tables.

CMPalmer