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
- support for hebrew calendar from 1970 to 2100
Happy holidays!
Table of Contents
Supported Countries, States, Regions
If you are missing holidays from your country, state, region please consider contributing.
Countries: 62
├── AD: Andorra
│ └── vella: Andorra la Vella
├── AM: Armenia
├── 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: България
├── BO: Bolivia
├── BR: Brazil
├── BZ: Belize
├── CA: Canada
├── 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á
├── CO: Colombia
├── CR: Costa Rica
├── CU: Cuba
├── CY: Cyprus
├── 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
├── EC: Ecuador
│ └── qu: Quito
├── EE: Eesti
├── ES: España
│ └── madrid: Comunidad de Madrid
├── 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
├── GB: Britain
│ ├── al: Alderney
│ ├── en: England
│ ├── gu: Guernsey
│ ├── im: Isle of Man
│ ├── je: Jersey
│ ├── ni: Northern Ireland
│ ├── sc: Scottland
│ └── wa: Wales
├── GD: Grenada
├── GR: Ελλάδα
├── GT: Guatemala
├── GU: Guam
├── HN: Honduras
├── HR: Hrvatska
│ ├── split: Split
│ └── dubrovnik: Dubrovnik
├── HU: Magyarország
├── IE: Ireland
├── IT: Italia
│ └── suedtirol: Südtirol, Alto Adige
├── IS: Iceland
├── JP: 日本
├── LI: Lichtenstein
├── LT: Lietuva
├── LU: Luxembourg
├── LV: Latvija
├── MC: Monaco
├── ME: Crna Gora
├── MX: México
├── MT: Malta
├── 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: Россия
├── SE: Sverige
├── SV: El Salvador
│ └── san: San Salvador
├── TR: Türkiye
├── VE: Venezuela
│ ├── an: Anzoátegui
│ ├── ca: Carabobo
│ ├── la: Lara
│ │ └── ba: Barquisimeto
│ ├── mi: Miranda
│ ├── mo: Monagas
│ ├── ta: Táchira
│ └── zu: Zulia
├── US: United States
│ ├── 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
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.
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