Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-10-2002, 06:21 PM   PM User | #1
Tanker
New Coder

 
Join Date: Jun 2002
Location: Northern California
Posts: 50
Thanks: 2
Thanked 0 Times in 0 Posts
Tanker is an unknown quantity at this point
Holiday Javascript....

Has anyone found or written a script to calculate when holidays will appear during the year?

I'm writing a script to send an alert if the data is not current but one of my cohorts in crime said "What about holidays?" to which i replied "Turn off your pager."

Unfortunately thats not a "good" solution, So here I am asking for help once again.

If I need to put in a base line of the holidays like starting in 2000 that would be fine also.

Thanks in advance...
Tanker is offline   Reply With Quote
Old 07-10-2002, 09:45 PM   PM User | #2
nolachrymose
Regular Coder

 
Join Date: Jun 2002
Posts: 338
Thanks: 0
Thanked 0 Times in 0 Posts
nolachrymose is an unknown quantity at this point
Could you be more specific about which holidays you want? But, let's say you want to see if it is July 4, you could use this script:

Code:
var date=new Date().getDate();
var month=new Date().getMonth()+1;

if(date==4&&month==7) alert("Happy Independenced Day!");
Hope that helps!

Happy coding!
nolachrymose is offline   Reply With Quote
Old 07-11-2002, 03:56 AM   PM User | #3
RadarBob
Regular Coder

 
Join Date: Jun 2002
Location: Round Rock, Texas
Posts: 443
Thanks: 0
Thanked 0 Times in 0 Posts
RadarBob is an unknown quantity at this point
Seems to me you need a more general solution than just holidays. I'd think you'd want to be able to "mark" any date - like vacations or sick days.

Off the top of my head I'd say implement an array of dates. Each date in the array is a day that you don't send that alert. Just scan the array and if today's date is there, well there you are. This will prevent you from having to test for (e.g. hard code) specific dates.

Additionally, you can store the year value such that you can tell if a particular date is recurring, or is just a one time thing. For example if you leave the year blank for July 4 then that means this is a recurring (annual) date. If the year is in there explicitly then when that day,month,year is past the date can be purged from the array.

If you want to get fancy, you might want to "encode" a date range; rather than enter each day of someone's 20 day vacation, you enter the beginning and ending date. In this case you'd need a sort of a more sophisticated data structure to know what dates are beginning and end dates, and what beginning/ending dates are paired. Off hand, I don't know what that might look like. You'd need a unique marker (key) for each pair and then an additional marker to know what is the beginning or end (or smart code to figure out that the earlier date of a given matched pair is the beginning).

You can have lots of fun with this. It has job security written all over it!
RadarBob is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:13 AM.


Advertisement
Log in to turn off these ads.