Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating holidays

Status
Not open for further replies.

weeze2

Technical User
Jun 18, 2002
129
0
0
DK
Hi Is there a way to calculate holidays in JavaScript

The VBA below does that by calculating Easter and then adding or subtracting some days to get to the rest.

I have tried to convert the code to JavaScript - the easter calculation works but the other holidays does not. Is it possible to calculate holidays just by using Easter as a fixpoint, and has anybody tried this in JavaScript before?

 
It's really difficult to get Easter calculations right - there is a whole page of information about calculating Easter here:


and more here:


Actually, public holidays are a pain in general, especially if your hoping to cover more than just England.

I'd pre-calulate ALL bank holidays for as far forward as you can get them and store them in a database somewhere.

Don't forget, public holidays can be added at will (didn't we get an additional public holiday in 1977 for the Queens Silver Jubilee) and this would require you to change your algorithm, as opposed to just setting a flag on a database record.

Chaz

Chaz
 
Actually, the extra bank holiday was in 2002 for the Queens Golden Jubilee.

They added an extra day (June 3rd) and moved the end of May holiday to June 4th for a 4 day weekend.

See what I mean.

Chaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top