Scriptcalendar.com
An Incredible Javascript Event Calendar

User Guide

»  Table Of Contents

Holidays

Section 3.4.1

Thanksgiving, Memorial day and Easter are difficult to code in the scevent.js file. These holidays don't happen on the same day every year like Christmas. The best way to handle these holidays in the spspcevt.js file.

Thanksgiving occurs on the 4th Thursday in November. In order to represent it, we must check for three things.

  • The month is November
  • It is the 4th week of the month
  • The weekday is Thursday

You perform all of these checks using the code below. The code relies on the variables provided within the spspcevt.js that are based on the date being rendered.

// Thanksgiving Day, fourth Thursday in November.
if (m==11 && intWeekday==4 && intWeekOfMonth==4) {
    objEvent = new EventObj(m,d,y, "Thanksgiving", null, "scEventRed");
    arrEvents[arrEvents.length] = objEvent;
};

Memorial Day is the last Monday in May. You can perform a similar check for it. Below is the code for a Memorial day event.

// Memorial Day, Last Monday in May.
if (m==5 && intWeekday==1 && blnLast==true) {
    objEvent = new EventObj(m,d,y, "Memorial Day", null, "scEventRed");
    arrEvents[arrEvents.length] = objEvent;
};

A much trickier holiday is the Easter holiday. To make it easier, the Scriptcalendar will provide the Easter holiday date in the variable dteEaster with the spspcevt.js. The variable gets the data from the calendar engine in a function named fscEaster. The year is passed into this function.

When you know the Easter holiday, you can also determine a date for Mardi Gras and Ash Wednesday.

// Easter Sunday
if (dte.equalsTo(dteEaster)) {
    objEvent = new EventObj(m,d,y, "Easter Sunday", null, "scEventRed");
    arrEvents[arrEvents.length] = objEvent;
};
// Mardi Gras (47 days before Easter Sunday)
if (dte.equalsTo(dteMardiGras)) {
    objEvent = new EventObj(m,d,y, "Mardi Gras", null, "scEventRed");
    arrEvents[arrEvents.length] = objEvent;
};

»  Table Of Contents