19

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.)

rook
  • 66,304
  • 38
  • 162
  • 239
Guy
  • 65,082
  • 97
  • 254
  • 325

8 Answers8

16

You can try http://kayaposoft.com/enrico/. Enrico Service is a free service providing public holidays for several countries including US. Public holidays for the countries like US or Germany are provided separately for each state. You can use either web service or json to get public holidays from Enrico.

Juraj Majer
  • 567
  • 5
  • 10
8

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
  • 57,123
  • 20
  • 76
  • 103
  • 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 Feb 25 '09 at 20:30
  • 1
    Interesting site, but it's so horribly designed (my eyes bled), and it doesn't have anything like isHoliday(date). – Cerin Mar 06 '10 at 21:52
  • I also searched for such a webservice few days ago and i found [this](http://www.holidaycalendarservice.com/) very promising holiday calendar web service. I think it is worth a try :) – funcoder Apr 17 '14 at 15:27
  • @funcoder - The site you provide appears to be for an API that is not yet available. Given how long ago that was, I'm guessing there won't be a final product available – Pedro Jan 27 '15 at 18:47
  • service: http://www.holidaywebservice.com/Holidays/US/USHolidayService.asmx/GetHolidaysForYear?year=2015 Documentation: http://www.holidaywebservice.com/Holidays/US/USHolidayService.asmx?op=GetHolidaysForYear – Lostlinkpr May 06 '15 at 19:08
  • 3
    holidaywebservice is gone... All links are broken. – mika Oct 23 '19 at 10:03
  • 2
    Just want to let you know this service is no more available on internet. – Sudhakar Chavali Oct 01 '20 at 18:00
6

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

ICAL HTML

live2
  • 3,771
  • 2
  • 37
  • 46
Brandon
  • 724
  • 1
  • 6
  • 8
5

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.

live2
  • 3,771
  • 2
  • 37
  • 46
CMPalmer
  • 8,571
  • 5
  • 40
  • 49
2

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

I am looking for something similar PL/SQL based. I found jollyday (sourceforge). It is java maybe you can use it with ikvm from c#. Sadly I was not able to load the java api into my oracle rdbms ... so ... if you came across a pure C or PL/SQL solution, please let me know :-)

Cheers Chris

christian
  • 425
  • 5
  • 15
1

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

Andrew Johnson
  • 7,277
  • 4
  • 23
  • 27
1

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.

Tom Kidd
  • 12,830
  • 19
  • 89
  • 128
  • 2
    Just be careful...the US Federal Holiday for Christmas is NOT always December 25. If that date falls on a weekend, the holiday is the closer of Friday or Monday. Likewise for Veterans Day and Independence Day. – mwolfe02 Nov 29 '12 at 17:36