What is date-holidays?
The date-holidays npm package is a comprehensive library for handling public holidays for various countries and regions. It allows you to query holidays, check if a specific date is a holiday, and get holiday names and details.
What are date-holidays's main functionalities?
Initialize Holidays for a Specific Country
This feature allows you to initialize the holidays for a specific country. In this example, the holidays for the United States are initialized.
const Holidays = require('date-holidays');
const hd = new Holidays('US');
Get Holidays for a Specific Year
This feature allows you to get a list of holidays for a specific year. The code sample retrieves the holidays for the year 2023.
const holidays = hd.getHolidays(2023);
console.log(holidays);
Check if a Specific Date is a Holiday
This feature allows you to check if a specific date is a holiday. The code sample checks if December 25, 2023, is a holiday.
const isHoliday = hd.isHoliday(new Date('2023-12-25'));
console.log(isHoliday);
Get Holiday Details for a Specific Date
This feature allows you to get detailed information about a holiday on a specific date. The code sample retrieves details for the holiday on December 25, 2023.
const holidayDetails = hd.getHoliday(new Date('2023-12-25'));
console.log(holidayDetails);
Set and Get Locale for Holiday Names
This feature allows you to set the locale for holiday names and retrieve holidays in that locale. The code sample sets the locale to Spanish and retrieves the holidays for 2023 in Spanish.
hd.setLocale('es');
const holidaysInSpanish = hd.getHolidays(2023);
console.log(holidaysInSpanish);
Other packages similar to date-holidays
moment-holiday
The moment-holiday package extends the Moment.js library to handle holidays. It provides similar functionalities such as checking if a date is a holiday and getting holiday names. However, it is built on top of Moment.js, which may be beneficial if you are already using Moment.js in your project.
holiday-jp
The holiday-jp package is specifically designed for Japanese holidays. It provides functionalities to check if a date is a holiday in Japan and to get a list of Japanese holidays. It is more specialized compared to date-holidays, which supports multiple countries.
node-holidayapi
The node-holidayapi package is a client for the Holiday API service. It allows you to query holidays for various countries and regions using the Holiday API. It requires an API key and offers more extensive data but depends on an external service.
date-holidays
world-wide holidays in gregorian calender
This module provides dates of holidays for various countries, states and regions by type while considering the applicable timezone.
The features are:
- calculation of public, bank and observance holidays for different countries, state, region
- consideration of timezones for holiday checks
- substitute days
- multi-language support for all holiday names
- setting of custom holidays
- uses own grammar for calculation of days
- support for islamic calendar from 1970 to 2080 (*islamic dates might not be correct as they are subject to the sighting of the moon)
- support for hebrew calendar from 1970 to 2100
- for generation of iCal calendar check out date-holidays-ical
Happy holidays!
Table of Contents
Supported Countries, States, Regions
If you are missing holidays from your country, state, region please consider contributing.
Countries: 89
├── AD: Andorra
│ └── vella: Andorra la Vella
├── AO: Angola
├── AM: Հայաստան
├── AR: Argentina
├── AT: Österreich
│ ├── b: Burgenland
│ ├── k: Kärnten
│ ├── n: Niederösterreich
│ ├── o: Oberösterreich
│ ├── s: Land Salzburg
│ ├── st: Steiermark
│ ├── t: Tirol
│ ├── v: Vorarlberg
│ └── w: Wien
├── AU: Australia
│ ├── act: Australian Capital Territory
│ ├── nsw: New South Wales
│ ├── nt: Northern Territory
│ ├── qld: Queensland
│ ├── sa: South Australia
│ ├── tas: Tasmania
│ │ ├── h: Hobart
│ │ └── nh: Non-Hobart
│ ├── vic: Victoria
│ │ └── m: Melbourne
│ └── wa: Western Australia
├── BE: Belgique
│ ├── de: Deutschsprachige Gemeinschaft
│ ├── fr: Communauté française
│ │ └── br: Bruxelles
│ └── vl: Vlaamse Gemeenschap
├── BG: България
├── BI: République du Burundi
├── BO: Bolivia
├── BR: Brasil
├── BS: Bahamas
├── BW: Botswana
├── BZ: Belize
├── CA: Canada
│ ├── ab: Alberta
│ ├── bc: British Columbia
│ ├── mb: Manitoba
│ ├── nb: New Brunswick
│ ├── nl: Newfoundland and Labrador
│ ├── ns: Nova Scotia
│ ├── nt: Northwest Territories
│ ├── nu: Nunavut
│ ├── on: Ontario
│ ├── pe: Prince Edward Island
│ ├── qc: Quebec
│ ├── sk: Saskatchewan
│ └── yt: Yukon
├── CD: République démocratique du Congo
├── CF: République centrafricaine
├── CH: Schweiz
│ ├── zh: Kanton Zürich
│ ├── be: Kanton Bern
│ ├── lu: Kanton Luzern
│ ├── ur: Kanton Uri
│ ├── sz: Kanton Schwyz
│ ├── ow: Kanton Obwalden
│ ├── nw: Kanton Nidwalden
│ ├── gl: Kanton Glarus
│ ├── zg: Kanton Zug
│ ├── fr: Kanton Freiburg
│ ├── so: Kanton Solothurn
│ ├── bs: Kanton Basel-Stadt
│ ├── bl: Kanton Basel-Landschaft
│ ├── sh: Kanton Schaffhausen
│ ├── ar: Kanton Appenzell Ausserrhoden
│ ├── ai: Kanton Appenzell Innerrhoden
│ ├── sg: Kanton St. Gallen
│ ├── gr: Kanton Graubünden
│ ├── ag: Kanton Aargau
│ ├── tg: Kanton Thurgau
│ ├── ti: Kanton Tessin
│ ├── vd: Kanton Waadt
│ ├── vs: Kanton Wallis
│ ├── ne: Kanton Neuenburg
│ ├── ge: Kanton Genf
│ └── ju: Kanton Jura
├── CL: Chile
│ ├── ar: Arica
│ ├── ch: Chillán y Chillán Viejo
│ ├── pa: Parinacota
│ └── ta: Tarapacá
├── CG: République du Congo
├── CM: Cameroun
├── CO: Colombia
├── CR: Costa Rica
├── CU: Cuba
├── CY: Κύπρος
├── CZ: Česká republika
├── DK: Danmark
├── DE: Deutschland
│ ├── bb: Brandenburg
│ ├── bw: Baden Würtemberg
│ ├── by: Bayern
│ │ └── a: Stadt Augsburg
│ ├── hb: Hansestadt Bremen
│ ├── he: Hessen
│ ├── hh: Hansestadt Hamburg
│ ├── mv: Mecklenburg Vorpommern
│ ├── ni: Niedersachsen
│ ├── nw: Nordrhein-Westfalen
│ ├── rp: Rheinland-Pfalz
│ ├── sh: Schleswig-Holstein
│ ├── sl: Saarland
│ ├── sn: Sachsen
│ ├── st: Sachsen-Anhalt
│ └── th: Thüringen
├── DO: República Dominicana
├── EC: Ecuador
│ └── qu: Quito
├── EE: Eesti
├── ES: España
│ └── madrid: Comunidad de Madrid
├── ET: ኢትዮጵያ
├── FI: Suomi
├── FR: France
│ ├── basrhin: Département Bas-Rhin
│ ├── hautrhin: Département Haut-Rhin
│ ├── moselle: Département Moselle
│ ├── mayotte: Département et région d'outre-mer Mayotte
│ ├── martinique: Département et région d'outre-mer Martinique
│ ├── guadeloupe: Département et région d'outre-mer Guadeloupe
│ ├── guyane: Département et région d'outre-mer Guyane
│ └── reunion: Département et région d'outre-mer La Réunion
├── GA: Gabon
├── GB: Britain
│ ├── al: Alderney
│ ├── en: England
│ ├── gu: Guernsey
│ ├── im: Isle of Man
│ ├── je: Jersey
│ ├── ni: Northern Ireland
│ ├── sc: Scottland
│ └── wa: Wales
├── GD: Grenada
├── GR: Ελλάδα
├── GQ: República de Guinea Ecuatorial
├── GT: Guatemala
├── GU: Guam
├── HN: Honduras
├── HR: Hrvatska
│ ├── split: Split
│ └── dubrovnik: Dubrovnik
├── HT: Haïti
├── HU: Magyarország
├── IE: Ireland
├── IT: Italia
│ └── suedtirol: Südtirol, Alto Adige
├── IS: Ísland
├── JM: Jamaica
├── JP: 日本
├── KE: KE
├── LI: Lichtenstein
├── LT: Lietuva
├── LU: Luxembourg
├── LV: Latvija
├── MC: Monaco
├── ME: Crna Gora
├── MG: Repoblikan'i Madagasikara
├── MX: México
├── MT: Malta
├── MZ: Moçambique
├── MW: Malawi
├── NA: Namibia
├── NI: Nicaragua
├── NL: Nederland
├── NO: Norge
├── NZ: New Zealand
│ ├── au: Auckland Province
│ ├── ca: Canterbury
│ ├── ch: Chatham Islands
│ ├── ha: Hawke's Bay
│ ├── ma: Marlborough
│ ├── ne: Nelson
│ ├── no: Northland
│ ├── ot: Otago Province
│ ├── sc: South Canterbury
│ ├── so: Southland
│ ├── ta: Taranaki
│ ├── we: Wellington Province
│ └── wd: Westland
├── PA: Panamá
├── PE: Perú
│ └── cu: Cuzco
├── PL: Polska
├── PT: Portugal
├── PY: Paraguay
├── RO: Romania
├── RU: Россия
├── RW: Repubulika y'u Rwanda
├── SE: Sverige
├── SS: South Sudan
├── SV: El Salvador
│ └── san: San Salvador
├── TG: République togolaise
├── TR: Türkiye
├── TZ: Tanzania
├── VE: Venezuela
│ ├── an: Anzoátegui
│ ├── ca: Carabobo
│ ├── la: Lara
│ │ └── ba: Barquisimeto
│ ├── mi: Miranda
│ ├── mo: Monagas
│ ├── ta: Táchira
│ └── zu: Zulia
├── UG: Uganda
├── US: United States of America
│ ├── al: Alabama
│ ├── ak: Alaska
│ ├── az: Arizona
│ ├── ar: Arkansas
│ ├── ca: California
│ ├── co: Colorado
│ ├── ct: Connecticut
│ ├── de: Delaware
│ ├── dc: District of Columbia
│ ├── fl: Florida
│ ├── ga: Georgia
│ ├── hi: Hawaii
│ ├── id: Idaho
│ ├── il: Illinois
│ ├── in: Indiana
│ ├── ia: Iowa
│ ├── ks: Kansas
│ ├── ky: Kentucky
│ ├── la: Louisiana
│ │ └── no: New Orleans
│ ├── me: Maine
│ ├── md: Maryland
│ ├── ma: Massachusetts
│ ├── mi: Michigan
│ ├── mn: Minnesota
│ ├── ms: Mississippi
│ ├── mo: Missouri
│ ├── mt: Montana
│ ├── ne: Nebraska
│ ├── nv: Nevada
│ ├── nh: New Hampshire
│ ├── nj: New Jersey
│ ├── nm: New Mexico
│ ├── ny: New York
│ ├── nc: North Carolina
│ ├── nd: North Dakota
│ ├── oh: Ohio
│ ├── ok: Oklahoma
│ ├── or: Oregon
│ ├── pa: Pennsylvania
│ ├── ri: Rhode Island
│ ├── sc: South Carolina
│ ├── sd: South Dakota
│ ├── tn: Tennessee
│ ├── tx: Texas
│ ├── ut: Utah
│ ├── vt: Vermont
│ ├── va: Virginia
│ ├── wa: Washington
│ ├── wv: West Virginia
│ ├── wi: Wisconsin
│ └── wy: Wyoming
├── UY: Uruguay
├── ZA: South Africa
├── ZM: Zambia
└── ZW: Zimbabwe
Usage
var Holidays = require('date-holidays')
var hd = new Holidays()
hd.getCountries()
hd.getStates('US')
hd.getRegions('US', 'la')
hd.init('US', 'la', 'no')
hd = new Holidays('US', 'la', 'no')
hd.getHolidays(2016)
hd.isHoliday(new Date('2016-02-09 00:00:00 GMT+0000'))
hd.isHoliday(new Date('2016-02-09 10:00:00 GMT-0600'))
Holiday object
getHolidays()
as well as a matching isHoliday()
call return either a list or a single holiday object which consists of:
- {String} date - ISO Date String of (start)-date in local format
- {Date} start - start date of holiday
- {Date} end - end date of holiday
- {String} name - name of holiday using
language
(if available) - {String} type - type of holiday
public|bank|school|observance
- {Boolean} substitute - (optional) if true holiday substitutes another holiday`
Dates
The date
String represents the start date of the holiday in ISO format without timezone.
This string it intented for information only.
start
and end
are the start/end date of the holiday within the selected timezone of the country, state, region.
Name
The name
names the holiday in the local language of the selected country, state, region. The applied language(s) can be requested using getLanguages()
.
The language can be changed using the setLanguages()
method. In case that not translation is available a fallback to the next given language will be made. E.g. local language is "fr", setLanguages('nl')
was called. For all holidays where no dutch translation is available the french version will be used instead.
All holiday names should support an english translation.
Types of holidays
Currently the following type with their meaning are supported
type | meaning |
---|
public | public holiday |
bank | bank holiday, banks and offices are closed |
school | school holiday, schools are closed |
optional | majority of people take a day off |
observance | optional festivity, no paid day off |
Additionally a note
field is sometimes available for further clarification.
API
See Holidays API for further information.
Data
All data for the holidays of the different countries is contained in ./data/holidays.yaml. Any details on structure and available grammar for holiday attribution is described in holidays.yaml specification.
Custom builds of holidays.json
If only selected countries are required in data/holidays.json
you can add the following script to your npm scripts section. E.g. for picking just US, Canada, Mexico do the following:
"scripts": {
"build": "holidays2json --pick US,CA,MX"
},
Alternatively you may use the --omit
option.
Manually use
$(npm bin)/holidays2json --pick US,CA,MX
NOTE: There are some countries which depend on data of others which
might render the file useless. e.g. "GU" requires "US", so try
to pick or omit both.
Contribution and License Agreement
You like to contribute please read CONTRIBUTING.md.
If you contribute code to this project, you are implicitly allowing your
code to be distributed under the ISC license. You are also implicitly
verifying that all code is your original work or correctly attributed
with the source of its origin and licence.
License
Copyright (c) 2016 commenthol (ISC License)
The data contained in holidays.yaml
is available under CC BY-SA 3.0 as the majority of data obtained relies on wikipedia articles.
The required attribution can be found inside the file
./data/holidays.yaml.
See LICENSE for more information.
References