Is Californian Holiday - Node.js Date

Node.js examples for Date:Day

Description

Is Californian Holiday

Demo Code


/**/* w  w  w. j a v  a 2s. c om*/
 * @description Sourced from the Franchise Tax Board of California.
 * @param {Date} day
 * @returns {Boolean}
*/
isCalifornianHoliday: function (day) {
  var holidays = [
    { month: 0, day: 1 },   // New Year's Day
    { month: 0, day: 18 },  // MLK Jr. Day
    { month: 1, day: 15 },  // President's Day
    { month: 2, day: 31 },  // Cesar Chavez Day
    { month: 4, day: 30 },  // Memorial Day
    { month: 6, day: 4 },   // Independence Day
    { month: 7, day: 5 },   // Labor Day
    { month: 10, day: 11 }, // Veteran's Day
    { month: 10, day: 24 }, // Thanksgiving Day
    { month: 10, day: 25 }, // Day after Thanksgiving
    { month: 11, day: 26 }  // Day after Christmas
  ];

  // Filter function...
  var findHoliday = function (holiday) {
    if (day.getMonth() === holiday.month
     && day.getDate() === holiday.day) {
       return holiday;
     }
  };

  return holidays.filter(findHoliday).length > 0;
}

Related Tutorials