Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Northern California
    Posts
    50
    Thanks
    2
    Thanked 0 Times in 0 Posts

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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Round Rock, Texas
    Posts
    443
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •