@date/holidays instance with USA public and bank holidays.
Also has functions to calculate dates for specific holidays.
npm install @date/holidays-us --save
// get Holidays instance with both public and bank holidaysvar holidays =var date = 2016 0 1 // New Year's Day 2016holidays // truedate // January 10th 2016holidays // falsedate = holidays // November 26th, 2015date = holidays // November 24th, 2016date = holidays // February 14th, 2016holidays // true, it's a holiday// this will return false because Valentine's Day isn't a bank holidayholidays
Only Bank Holidays
// this has only the bank holidays, not the 'public' onesvar holidays =// returns false, Valentine's isn't a bank holidayholidays// returns true, New Year's is a bank holidayholidays
Only Public Holidays
// this has only the non-bank holidaysvar holidays =// returns true, Valentine's is a public holidayholidays// returns false, because New Year's is a bank holidayholidays// NOTE: technically, I suppose the bank holidays are also// public holidays, but, if you want both, use the default// instance which has both
Functions which generate a specific holiday based on a specified year:
- newYearsDay() - can calculate observed holiday as well
- independenceDay() - can calculate observed holiday as well
- veteransDay() - can calculate observed holiday as well
- christmas() - can calculate observed holiday as well
API: Observed Holidays
Some holidays are "observed" on a different day than the holiday. The generate functions can calculate that as well.
var holidays =// Christmas in 2016 is on a Sunday so it is "observed" the next day, Monday.// the call to the generator returns the date instance as expectedvar christmasDay = holidays // same as new Date(2016, 11, 25)// it also has an `observed` property containing the "observed" holiday date// Note: if there is no "observed" holiday then `observed` is undefinedvar observedChristmas = dateobserved// christmas == new Date(2016, 11, 25) Sunday, December 25th 2016// observedChristmas == new Date(2016, 11, 26) Monday, December 26th 2016