Jump to content

[SOLVED] Help needed with Javascript


jdadwilson

Recommended Posts

First let me say I am a complete newbie to javascript.

 

I found the following script recently. Its purpose is to identify if a date is a holiday. Looks very good. Problem is this I have no clue as to the required format of the input variable.

 

Any help is greatly appreciated.

 

TIA... here is a snippet of the function.

 

function check_holiday (dt_date) {

 

// check simple dates (month/date - no leading zeroes)

var n_date = dt_date.getDate(),

n_month = dt_date.getMonth() + 1;

var s_date1 = n_month + '/' + n_date;

 

if ( s_date1 == '1/1' // New Year's Day

|| s_date1 == '6/14' // Flag Day

|| s_date1 == '7/4' // Independence Day

|| s_date1 == '11/11' // Veterans Day

|| s_date1 == '12/25' // Christmas Day

) return true;

 

return false;

}

Link to comment
Share on other sites

looks like its being passed a date object, consider the following...

 

// checks to see if todays date is a holiday
var dt_date= new Date();
if(check_holiday (dt_date)) {
    alert("date OK");
}

// check another date
var dt_date= new Date("October 12, 1988");
if(check_holiday (dt_date)) {
    alert("date OK");
}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.