Giter Club home page Giter Club logo

date-holidays's Introduction

date-holidays

world-wide holidays in gregorian calender

NPM version Build Status

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, following ISO 3166-2
  • consideration of timezones for holiday checks
  • consideration of start and end time dependent on timezone
  • 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
  • support for chinese calendar
  • 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: 197
├── AD: Andorra
│   └── 07: Andorra la Vella
├── AE: دولة الإمارات العربية المتحدة
├── AG: Antigua & Barbuda
│   └── 10: Barbuda
├── AI: Anguilla
├── AL: Shqipëri
├── AM: Հայաստան
├── AO: Angola
├── AR: Argentina
├── AS: American Samoa
├── AT: Österreich
│   ├── 1: Burgenland
│   ├── 2: Kärnten
│   ├── 3: Niederösterreich
│   ├── 4: Oberösterreich
│   ├── 5: Land Salzburg
│   ├── 6: Steiermark
│   ├── 7: Tirol
│   ├── 8: Vorarlberg
│   └── 9: Wien
├── AU: Australia
│   ├── ACT: Australian Capital Territory
│   ├── NSW: New South Wales
│   ├── NT: Northern Territory
│   ├── QLD: Queensland
│   ├── SA: South Australia
│   ├── TAS: Tasmania
│   ├── VIC: Victoria
│   └── WA: Western Australia
├── AW: Aruba
├── AX: Landskapet Åland
├── AZ: Azərbaycan Respublikası
├── BA: Bosna i Hercegovina
│   ├── BIH: Federation of Bosnia and Herzegovina
│   │   └── W: Western Herzegovina
│   ├── BRC: Brčko District
│   └── SRP: Republika Srpska
├── BB: Barbados
├── BD: গণপ্রজাতন্ত্রী বাংলাদেশ
├── BE: Belgique
│   ├── BRU: Bruxelles
│   ├── DE: Deutschsprachige Gemeinschaft
│   ├── VLG: Vlaamse Gemeenschap
│   └── WAL: Communauté française
├── BF: Burkina Faso
├── BG: България
├── BH: مملكة البحرين
├── BI: République du Burundi
├── BJ: République du Bénin
├── BL: St. Barthélemy
├── BM: Bermuda
├── BN: Negara Brunei Darussalam
├── BO: Bolivia
│   ├── B: Beni
│   ├── C: Cochabamba
│   ├── H: Chuquisaca
│   ├── L: La Paz
│   ├── N: Pando
│   ├── O: Oruro
│   ├── P: Potosí
│   ├── S: Santa Cruz
│   └── T: Tarija
├── BQ: Caribisch Nederland
│   ├── BO: Bonaire
│   ├── SA: Saba
│   └── SE: Sint Eustatius
├── BR: Brasil
│   ├── AC: Acre
│   ├── AL: Alagoas
│   ├── AM: Amazonas
│   ├── AP: Amapá
│   ├── BA: Bahia
│   ├── CE: Ceará
│   ├── DF: Distrito Federal
│   ├── MA: Maranhão
│   ├── MG: Minas Gerais
│   │   └── BH: Belo Horizonte
│   ├── MS: Mato Grosso do Sul
│   ├── MT: Mato Grosso
│   ├── PA: Pará
│   ├── PB: Paraíba
│   ├── PE: Pernambuco
│   │   └── RE: Recife
│   ├── PI: Piauí
│   ├── PR: Paraná
│   │   └── CU: Curitiba
│   ├── RJ: Rio de Janeiro
│   │   └── RJ: Rio de Janeiro
│   ├── RN: Rio Grande do Norte
│   ├── RO: Rondônia
│   ├── RR: Roraima
│   ├── RS: Rio Grande do Sul
│   ├── SC: Santa Catarina
│   ├── SE: Sergipe
│   ├── SP: São Paulo
│   │   └── SP: São Paulo
│   └── TO: Tocantins
├── BS: Bahamas
├── BW: Botswana
├── BY: Рэспубліка Беларусь
├── 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
├── CC: Cocos (Keeling) Islands
├── CD: République démocratique du Congo
├── CF: République centrafricaine
├── CG: République du Congo
├── 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: Canton de Fribourg
│   ├── 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: Canton Ticino
│   ├── VD: Canton de Vaud
│   ├── VS: Canton du Valais
│   ├── NE: Canton de Neuchâtel
│   ├── GE: Canton de Genève
│   └── JU: Canton du Jura
├── CI: République de Côte d'Ivoire
├── CK: Cook Islands
│   ├── Aitutaki: Aitutaki
│   ├── Atiu: Atiu
│   ├── Mangaia: Mangaia
│   ├── Manihiki: Manihiki
│   ├── Mitiaro: Mitiaro
│   ├── Palmerston: Palmerston
│   ├── Penrhyn: Penrhyn
│   ├── Pukapuka: Pukapuka
│   ├── Rakahanga: Rakahanga
│   └── Rarotonga: Rarotonga
├── CL: Chile
│   ├── AP: Arica y Parinacota
│   ├── BI: Biobío
│   │   └── CH: Chillán y Chillán Viejo
│   ├── NU: Ñuble
│   │   └── CH: Chillán y Chillán Viejo
│   └── TA: Tarapacá
├── CM: Cameroun
├── CN: 中华人民共和国
├── CO: Colombia
├── CR: Costa Rica
├── CU: Cuba
├── CV: República de Cabo Verde
│   └── S: Sotavento Islands
│       └── PR: Praia
├── CW: Curaçao
├── CX: Christmas Island
├── CY: Κύπρος
├── CZ: Česká republika
├── DE: Deutschland
│   ├── BB: Brandenburg
│   ├── BE: Berlin
│   ├── BW: Baden-Württemberg
│   ├── BY: Bayern
│   │   ├── A: Stadt Augsburg
│   │   └── EVANG: Überwiegend evangelische Gemeinden
│   ├── 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
│   │   └── BZ: Landkreis Bautzen
│   ├── ST: Sachsen-Anhalt
│   └── TH: Thüringen
│       ├── EIC: Landkreis Eichfeld
│       ├── UH: Unstrut-Hainich-Kreis
│       └── WAK: Wartburgkreis
├── DJ: République de Djibouti
├── DK: Danmark
├── DM: Dominica
├── DO: República Dominicana
├── DZ: الجمهورية الجزائرية الديمقراطية الشعبية
├── EC: Ecuador
│   └── P: Pichincha
│       └── QU: Quito
├── EE: Eesti
├── EG: جمهورية مصر العربية
├── EH: الجمهورية العربية الصحراوية الديمقراطية
├── ER: Eritrea
├── ES: España
│   ├── AN: Andalucía
│   ├── AR: Aragón
│   ├── AS: Asturias
│   ├── CB: Cantabria
│   ├── CE: Ciudad de Ceuta
│   ├── CL: Castilla y León
│   ├── CM: Castile-La Mancha
│   ├── CN: Islas Canarias
│   │   ├── EH: El Hierro
│   │   ├── FU: Fuerteventura
│   │   ├── GC: Gran Canaria
│   │   ├── LG: La Gomera
│   │   ├── LP: La Palma
│   │   ├── LA: Lanzarote
│   │   └── TE: Tenerife
│   ├── CT: Cataluña
│   ├── EX: Extremadura
│   ├── GA: Galicia
│   ├── IB: Illes Balears
│   ├── MC: Murcia Region
│   ├── MD: Comunidad de Madrid
│   ├── ML: Ciudad de Melilla
│   ├── NC: Comunidad Foral de Navarra
│   ├── PV: País Vasco
│   ├── RI: La Rioja
│   └── VC: Comunitat Valenciana
├── ET: ኢትዮጵያ
├── FI: Suomi
├── FJ: Matanitu Tugalala o Viti
├── FO: Føroyar
├── FR: France
│   ├── 57: Département Moselle
│   ├── 67: Département Bas-Rhin
│   ├── 68: Département Haut-Rhin
│   ├── YT: Département et région d'outre-mer Mayotte
│   ├── MQ: Département et région d'outre-mer Martinique
│   ├── GP: Département et région d'outre-mer Guadeloupe
│   ├── GF: Département et région d'outre-mer Guyane
│   ├── RE: Département et région d'outre-mer La Réunion
│   ├── MF: Département et région d'outre-mer Saint Martin
│   └── BL: Département et région d'outre-mer Saint Barthélemy
├── GA: Gabon
├── GB: United Kingdom
│   ├── ALD: Alderney
│   ├── ENG: England
│   ├── NIR: Northern Ireland
│   ├── SCT: Scotland
│   └── WLS: Wales
├── GD: Grenada
├── GE: საქართველო
├── GF: Guyane
├── GG: Guernsey
├── GH: Ghana
├── GI: Gibraltar
├── GL: Kalaallit Nunaat
├── GM: The Gambia
├── GN: Guinée
├── GP: Guadeloupe
├── GQ: República de Guinea Ecuatorial
├── GR: Ελλάδα
├── GT: Guatemala
├── GU: Guam
├── GW: Guiné-Bissau
├── GY: Guyana
├── HK: 香港
├── HN: Honduras
├── HR: Hrvatska
│   ├── 17: Split-Dalmatia
│   └── 19: Dubrovnik-Neretva
├── HT: Haïti
├── HU: Magyarország
├── IC: Islas Canarias
│   ├── EH: El Hierro
│   ├── FU: Fuerteventura
│   ├── GC: Gran Canaria
│   ├── LG: La Gomera
│   ├── LP: La Palma
│   ├── LA: Lanzarote
│   └── TE: Tenerife
├── ID: Indonesia
├── IE: Ireland
├── IL: מְדִינַת יִשְׂרָאֵל
├── IM: Isle of Man
├── IR: جمهوری اسلامی ایران
├── IS: Ísland
├── IT: Italia
│   ├── 25: Lombardy
│   │   └── MI: Milan
│   └── 32: Südtirol, Alto Adige
├── JE: Jersey
├── JM: Jamaica
├── JP: 日本
├── KE: Kenya
├── KM: Union des Comores
├── KN: St. Kitts & Nevis
├── KR: 대한민국
├── KY: Cayman Islands
├── LC: St. Lucia
├── LI: Lichtenstein
├── LR: Liberia
├── LS: \'Muso oa Lesotho
├── LT: Lietuva
├── LU: Luxembourg
├── LV: Latvija
├── LY: دولة ليبيا
├── MA: المملكة المغربية
├── MC: Monaco
├── MD: Republica Moldova
│   ├── CA: Cahul
│   └── CU: Chișinău
├── ME: Crna Gora
├── MF: Saint Martin
├── MG: Repoblikan'i Madagasikara
├── MK: Република Македонија
├── ML: République du Mali
├── MQ: Martinique
├── MR: الجمهورية الإسلامية الموريتانية
├── MS: Montserrat
├── MT: Malta
├── MW: Malawi
├── MX: México
├── MY: Malaysia
│   ├── 10: Selangor
│   ├── 11: Terengganu
│   ├── 12: Sabah
│   ├── 13: Sarawak
│   ├── 14: Kuala Lumpur
│   ├── 15: Labuan
│   ├── 16: Putrajaya
│   ├── 01: Johor
│   ├── 02: Kedah
│   ├── 03: Kelantan
│   ├── 04: Malacca
│   ├── 05: Negeri Sembilan
│   ├── 06: Pahang
│   ├── 07: Penang
│   ├── 08: Perak
│   └── 09: Perlis
├── MZ: Moçambique
├── NA: Namibia
├── NC: Nouvelle-Calédonie
├── NE: République du Niger
├── NG: Nigeria
├── NI: Nicaragua
├── NL: Nederland
├── NO: Norge
├── NZ: New Zealand
│   ├── AUK: Auckland Province
│   ├── BOP: Bay of Plenty
│   ├── CAN: Canterbury
│   │   └── Timaru: Timaru District
│   ├── CIT: Chatham Islands
│   ├── GIS: Gisborne
│   ├── HKB: Hawke's Bay
│   ├── MBH: Marlborough
│   ├── MWT: Manawatu-Wanganui
│   ├── NSN: Nelson
│   ├── NTL: Northland
│   ├── OTA: Otago Province
│   ├── STL: Southland
│   ├── TAS: Tasman
│   ├── TKI: Taranaki
│   ├── WKO: Waikato
│   ├── WGN: Wellington Province
│   └── WTC: Westland
│       └── Buller: Buller district
├── PA: Panamá
├── PE: Perú
│   └── CUS: Cuzco
├── PH: Philippines
├── PL: Polska
├── PM: St. Pierre & Miquelon
├── PR: Puerto Rico
├── PT: Portugal
├── PY: Paraguay
├── RE: Réunion
├── RO: Romania
├── RS: Република Србија
├── RU: Россия
├── RW: Rwanda
├── SC: Seychelles
├── SD: جمهورية السودان
├── SE: Sverige
├── SG: Singapore
├── SH: St. Helena
│   ├── AC: Ascension Island
│   ├── HL: Saint Helena
│   └── TA: Tristan da Cunha
├── SI: Republika Slovenija
├── SJ: Svalbard & Jan Mayen
├── SK: Slovenská republika
├── SL: Sierra Leone
├── SM: San Marino
├── SN: République du Sénégal
├── SO: Jamhuuriyadda Federaalka Soomaaliya
│   ├── AW: Awdal
│   ├── SA: Sanaag
│   ├── SO: Sool
│   ├── TO: Togdheer
│   └── WO: Woqooyi Galbeed
├── SR: Suriname
├── SS: South Sudan
├── ST: São Tomé & Príncipe
├── SV: El Salvador
│   └── SS: San Salvador
├── SX: Sint Maarten
├── SZ: Eswatini
├── TC: Turks & Caicos Islands
├── TD: جمهورية تشاد
├── TG: République togolaise
├── TH: Thailand
├── TN: الجمهورية التونسية
├── TO: Puleʻanga Fakatuʻi ʻo Tonga
├── TR: Türkiye
├── TT: Trinidad & Tobago
├── TW: 中華民國
├── TZ: Tanzania
├── UA: Україна
├── UG: Uganda
├── US: United States of America
│   ├── AL: Alabama
│   ├── AK: Alaska
│   ├── AZ: Arizona
│   ├── AR: Arkansas
│   ├── CA: California
│   │   └── LA: Los Angeles
│   ├── 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
├── VA: Stato della Città del Vaticano
├── VC: St. Vincent & Grenadines
├── VE: Venezuela
│   ├── B: Anzoátegui
│   ├── G: Carabobo
│   ├── K: Lara
│   │   └── BA: Barquisimeto
│   ├── M: Miranda
│   ├── N: Monagas
│   ├── S: Táchira
│   └── V: Zulia
├── VG: British Virgin Islands
├── VI: U.S. Virgin Islands
├── VN: Cộng hòa Xã hội chủ nghĩa Việt Nam
├── VU: République de Vanuatu
├── XK: Republika e Kosovës
├── YT: Mayotte
├── ZA: South Africa
├── ZM: Zambia
└── ZW: Zimbabwe

Usage

var Holidays = require('date-holidays')
var hd = new Holidays()

// get supported countries
hd.getCountries()
/*>
{ AD: 'Andorra',
  ...
  US: 'United States' }
*/

// get supported states e.g. for US
hd.getStates('US')
/*>
{ al: 'Alabama',
  ...
  wy: 'Wyoming' }
*/

// get supported regions e.g. for US, Lousiana
hd.getRegions('US', 'la')
/*>
{ no: 'New Orleans' }
*/

// initialize holidays for US, Lousiana, New Orleans
hd.init('US', 'la', 'no')
// or using a new instance
hd = new Holidays('US', 'la', 'no')

// get all holidays for the year 2016
hd.getHolidays(2016)
/*>
[ { date: '2016-01-01 00:00:00',
    start: Fri Jan 01 2016 00:00:00 GMT-0600 (CST),
    end: Sat Jan 02 2016 00:00:00 GMT-0600 (CST),
    name: 'New Year\'s Day',
    rule: '01-01 and if sunday then next monday if saturday then previous friday',
    type: 'public' },
  ...
  { date: '2016-11-24 00:00:00',
    start: Thu Nov 24 2016 00:00:00 GMT-0600 (CST),
    end: Fri Nov 25 2016 00:00:00 GMT-0600 (CST),
    name: 'Thanksgiving Day',
    rule: '4th thursday in November',
    type: 'public' },
  ...
  { date: '2016-12-26 00:00:00',
    start: Mon Dec 26 2016 00:00:00 GMT-0600 (CST),
    end: Tue Dec 27 2016 00:00:00 GMT-0600 (CST),
    substitute: true,
    name: 'Christmas Day (substitute day)',
    rule: '12-25 and if sunday then next monday if saturday then previous friday',
    type: 'public' } ]
*/

// check if date is a holiday while respecting timezones
hd.isHoliday(new Date('2016-02-09 00:00:00 GMT+0000'))
//> false
hd.isHoliday(new Date('2016-02-09 10:00:00 GMT-0600'))
/*>
[{ date: '2016-02-09 00:00:00',
  start: Tue Feb 09 2016 00:00:00 GMT-0600 (CST),
  end: Wed Feb 10 2016 00:00:00 GMT-0600 (CST),
  name: 'Mardi Gras',
  rule: 'easter -47',
  type: 'public' }
]
*/

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|optional|observance
  • {Boolean} substitute - (optional) if true holiday substitutes another holiday`
  • {String} note - (optional) note`

Dates

The date String represents the start date of the holiday in ISO format without timezone. This string it intended 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 fall-back 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.json. For changing holiday data edit the appropriate country in ./data/countries. 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 --min"
},

The --min switch removes dependencies which are not required for the countries selected. You may not be able to use the full set of rules in case you want to add custom rules.

Alternatively you may use the --omit option.

Manually use

npx 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.

Bundling with webpack

To minimize bundle sizes consider adding the following lines in your webpack config. Please take a look at ./webpack.config.js. To further reduce size consider custom builds by only selecting required countries.

...
  plugins: [
    new webpack.IgnorePlugin({
      checkResource (resource, context) {
        // ---- do not bundle astronomia vsop planet data
        if (/\/astronomia\/data$/.test(context)) {
          return !['./deltat.js', './vsop87Bearth.js'].includes(resource)
        }
        // ---- do not bundle moment locales
        if (/\/moment\/locale$/.test(context)) {
          return true
        }
        return false
      }
    })

Browser

This project also runs in all modern browsers. See ./examples/browser

Browser Version Notes
Chrome >=45
Firefox >=45
Safari >=10
Edge >=13
IE >=11 needs polyfill core-js/es6

Please do not forget to set the correct charset!

<html>
<head>
  <!-- set page-wide -->
  <meta charset="UTF-8">
  ...
</head>
<body>
  ...
  <!-- or per script -->
  <script src="your-bundle.js" charset="UTF-8"></script>

CDN

Minified distribution bundles are available via https://unpkg.com

NOTE: dist-bundles are quite huge in size ~1.5MByte so use custom builds instead.

See https://unpkg.com/date-holidays/dist/

  • index.min.js: commonjs2 bundle
  • umd.min.js: umd bundle

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 license.

License

Copyright (c) 2016- commenthol (ISC License)

The data contained in holidays.json and ./data/countries/*.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 files ./data/countries/*.yaml.

See LICENSE for more information.

References

date-holidays's People

Contributors

adminy avatar brandonbay avatar commenthol avatar crandrade avatar damon02 avatar davidan90 avatar gedclack avatar germain-receeve avatar gerryster avatar havardnyboe avatar hnw avatar iiome avatar janisumak avatar jhordyess avatar jwh-hutchison avatar kevinsamoei avatar konstantinoskouk90 avatar leipert avatar nanodino avatar nilsmehlhorn avatar olragon avatar oscarlgz avatar osoken avatar pero5ar avatar seb735 avatar svict4 avatar tristdrum avatar trolez avatar wayne-rebl avatar zbypy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

date-holidays's Issues

AU - NSW holidays

According to http://www.industrialrelations.nsw.gov.au/oirwww/NSW_public_holidays/NSW_Public_Holidays.page (which is already in your code comments), there is no public holiday on 31st December for AU/NSW, yet the code has got it specified. Why is this so?

Also, npm test doesn't pass when I tried running it (even without modifications), I get lots of errors, mostly off by half an hour, so I wasn't confident enough to submit a pull request.

I'm using Arch Linux with the latest tzdata-2016j installed, if that indicates anything...

Suggestion: create a folder with a "holiday dates" json file for each region

have a 'distribution' json directory of holiday dates,
i.e. json only, no code
e.g, so i can just pick up /dates/GB/England-Wales.json or /dates/GB/GB.json from the CDN or npm ....
=> its programming language independent
=> its very small (most people will just need 1 or 2 small files with a handful of dates (their country and possibly, region)
=> have 2 option, an, 'array of dates => name' file, and an 'object of names => date' file, so people can choose what they need.

Demo site

FYI day names have shifted on the demo site? For example, 2019 holidays for Australia list Good Friday, 19th April on Thursday.

proposal: unique identifier for holiday

Hi again,

I wanted to run something by you to see what you thought or if you have a better solution.

In my use case, I need to be able to automatically apply holiday surcharges to appointments that fall on a holiday. Each business has a list of observed holidays, so when a customer schedules an appointment, I first need to check to see if the business observes the holiday and if they do, then check to ensure the date of the appointment falls on the holiday. For the first part, I'm currently matching a list of holiday names to what's output by the getHolidays(year) function of your library. This works great, but I'd prefer to match on some unique identifier rather than a language-dependent name.

Would you be open to adding unique identifiers for holidays that would be the same regardless of language? Do you have a better solution that I may be missing?

Thanks!

Symfony installation

Hi there,

sorry im new bee.
Whats the best way to install under Symfony? Just put the folder in my assets or is there a better way?

THX
Mike

Make holidays.json a compiled asset instead of checked into version control?

Disclaimer: this is not an issue but a request for comment. However, a Github issue seems like the closest thing to an RFC.

I am wondering if it makes sense to remove data/holidays.json from version control and move the YAML to JSON process into the build process? Specifically, it would mean moving node scripts/holidays2json.js into the scripts/build step of package.json. This way, the full holidays.json would be packaged with the node module. It would also line up a bit more closely when customizing which countries exist in holidays.json.

I would also like this from a development standpoint. In the past, I have had merge conflicts with holidays.json which were more of an annoyance as I was able to regenerate the file on my branch.

What do you think?

examples/browser typo for index.html javascript resource

there is a typo in index.html file

on line 36 includes javascript file "index.js" when in fact it's "test.js"

current
<script src="index.js" type="text/javascript"></script>

should be
<script src="test.js" type="text/javascript"></script>

isHoliday function doesn't work

Hello,

I tried to use one of the readme example but I got an error

date-holidays installed : 1.4.0
chrome : 74.0.3729.169

My code ( in a react component):
var hd = new Holidays( 'FR' );

// working
console.log( hd.getHolidays() );

// Uncaught TypeError: Cannot read property 'fn' of undefined
hd.isHoliday( new Date( '2016-02-09 00:00:00 GMT+0000' ) )

Did I forget . to init something ?

[Feature Request] holiday function for searching for holidays using keywords

Hi there! I am the maker of https://github.com/kodie/moment-holiday and I'm considering switching my holiday source to your package here. Unfortunately, this package is missing one feature that I need, to be able to search for holidays using keywords.

I could implement this in my package and have something like keywords.json in it, but I think it would be better for everyone if the keywords were contained in the same package as the data source.

So my suggestion is to implement a holiday function for searching for holidays using keywords.

For example:

var hd = new Holidays('US')
hd.holiday('Memorial Day')

This would involve adding the keywords and keywords_n to the holidays.yaml structure.

Both of these keys would accept an array of strings and/or regex strings. keywords would be used as expected and keywords_n would be for values that shouldn't apply to that holiday. For example, the holiday Christmas Day would have ['christ', 'x-?mas'] in it's keywords and ['eve'] in it's keywords_n.

I would be more than happy to work on this and submit a pull request.

Holidays dont load correctly

For holidays in Australia, instantiating holidays using an object doesn't work.

For example the following fails, creating an instance with an empty {} instead of a set of holidays

const holidays = new Holidays({country: 'AU', state: 'NSW'});

Whereas this creates holidays as expected

const holidays = new Holidays('AU', 'NSW');

Reformation Day is doubled in some states of Germany

const Holiday = require('./lib/index')
const public = new Holiday('DE', 'mv')
  .getHolidays(2017)
  .filter(h => h.type == 'public')
  .filter(h => h.date.match(/2017-10-31/));
console.log(public)

produces following output:

[ { date: '2017-10-31 00:00:00',
    start: Tue Oct 31 2017 00:00:00 GMT+0100 (CET),
    end: Wed Nov 01 2017 00:00:00 GMT+0100 (CET),
    name: 'Reformationstag',
    type: 'public' },
  { date: '2017-10-31 00:00:00',
    start: Tue Oct 31 2017 00:00:00 GMT+0100 (CET),
    end: Wed Nov 01 2017 00:00:00 GMT+0100 (CET),
    name: 'Reformationstag',
    type: 'public' } ]

I guess it has something to do with it being celebrated as the country-wide holiday in 2017 only

Failed to minify the code

When using create-react-app there is problem with minifying.
./node_modules/date-holidays-parser/src/CalEvent.js:3

Please read more here: http://bit.ly/2tRViJ9

Ps. we can't edit webpack config file in create-react-app environment.

Berlin is missing

Hi,

there is no state 'Berlin' in the country 'DE'. In fact Berlin is a state of it's own and has different holidays than Brandenburg.

Denmark is missing one holiday

Hi

Really great plugin. Though one day is missing from the list when I pull danish holidays.
It's 24th of dec. Christmas Eve in Denmark, it's a public holiday as well.

Error using holidays2json example

When attempting to create a custom build using the example

"scripts": {
  "build": "holidays2json --pick US,CA,MX --min"
},

I got the following

npm run build
Error: got #ifndef expected #elif, #else, #endif
    at Parser._isCmd (/Users/xxx/node_modules/prepin/lib/parser.js:55:13)
    at /Users/xxx/node_modules/prepin/lib/parser.js:43:17
    at Array.map (<anonymous>)
    at Parser.parse (/Users/xxx/node_modules/prepin/lib/parser.js:34:29)
    at /Users/xxx/node_modules/prepin/lib/index.js:20:27
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

Using

$ npm -v
6.4.1
$ node -v
v8.12.0

Is it compatible with Node.js?

Minifing error with create-react-app

Hi,
First of all, thank you for this module! When I try to use it with create-react-app, an errror occurs during the npm run build command. It says:

Failed to minify the code from this file: 

 	./node_modules/date-holidays-parser/src/CalEvent.js:3 

Any help?

Thank you!

DE-BE: All Hallows no holiday

The 1st of November is the 'All Hallows' (Allerheiligen) holiday. For Berlin - Germany this is no holiday.
The library also detects the 2nd of November as the same holiday.

Request for Hanukkah

We request that Hanukkah be added, if that is possible, given that the dates change each year. Thank you!

Provide better scaling data files

Thanks for setting up this project!
I'd like to use it but I only need the holidays of a certain set of countries.
The current https://github.com/commenthol/date-holidays/blob/master/data/holidays.json contains all countries/regions and translations.
Since I am aiming to keep my app bundle size at a small size I wonder if we could organize the data json differently?

While I could implement a pre-build step and remove all the countries not needed I think other users might also gain something if the data could be included more fine grained.

CH: Swiss Stefanstag needs new rule

Kanton Uri, Kanton Appenzell A. Rh. and Kanton Appenzell I. Rh. require a new rule that holiday 12-26 (Stefanstag) is a holiday only if not falling on a Monday or Friday.

Missing Summer bank holiday in Northern Ireland

According to https://www.gov.uk/bank-holidays#northern-ireland, the Summer bank holiday is observed in Northern Ireland. However, when I scope to GB and the NIR (Norther Ireland) region, that holiday does not appear:

const Holidays = require('date-holidays')
const gb_nir = new Holidays('GB', 'NIR')
gb_nir.getHolidays(2018).filter((h) => h.name == 'Summer bank holiday') // returns [] but should return the Summer bank holiday.

Note that it does work correctly for England:

const gb_eng = new Holidays('GB', 'ENG')
gb_eng.getHolidays(2018).filter((h) => h.name == 'Summer bank holiday')

/* return value:
[ { date: '2018-08-27 00:00:00',
    start: 2018-08-26T23:00:00.000Z,
    end: 2018-08-27T23:00:00.000Z,
    name: 'Summer bank holiday',
    type: 'public' } ]
*/

Doesn't compile with commonjs

I'm using date-holidays in my angular project. Everything works fine but my unit tests all fail after importing it. It looks like date-holidays won't compile with commonjs module:

Uncaught TypeError: date_holidays_1.default is not a constructor

Here is my tsconig.spec

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "baseUrl": "./",
    "module": "commonjs",  <-- changing so something like "es2015" works fine (but breaks other things not related to date-holdays. I need to keep it as commonjs)
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

Filtering by multiple holiday types is not working as expected

Based on the API documentation, I was expecting to be able to pass an array of holiday types to Holidays.init and have it return only holidays of those types. For example:

const Holidays = require('date-holidays');
const us_all = new Holidays('us');
new Set(us_all.getHolidays(2018).map(h => h.type))
// returns Set { 'public', 'observance', 'optional' } as expected

# filtering by a single type works as expected:
const us_optional = new Holidays('us', {types: ['optional']})
new Set(us_optional.getHolidays(2018).map(h => h.type))
// returns Set { 'optional' }

# But filtering by multiple types returns nothing:
const us_optional_public = new Holidays('us', {types: ['optional', 'public']})
new Set(us_optional_public.getHolidays(2018).map(h => h.type))
// returns Set {} but I am expecting Set{'optional', 'public'}

Note that I am running this on Node 10 which has support for the new Set type. I am also running this against master as of 4768392 .

I am not sure if this is a documentation bug but it would be nice to be able to filter by multiple types.

US Veterans Day note is missing for some states/years on node@10 and node@8

On node 10.15.x and 8.x note is missing for some years for US Veterans Day

     "name": "Veterans Day",
     "type": "public",
+    "note": "Federal Government offices are closed",

On [email protected] all notes a present.
Not sure if there is a problem with the parser or with node?

Affected fixtures:

US-AK-2016.json
US-AK-2017.json
US-AK-2018.json
US-AK-2019.json
US-AK-2020.json
US-AL-2016.json
US-AL-2017.json
US-AL-2018.json
US-AL-2019.json
US-AL-2020.json
US-CA-2015.json
US-CA-2016.json
US-CA-2020.json
US-CA-LA-2015.json
US-CA-LA-2016.json
US-CA-LA-2017.json
US-CA-LA-2018.json
US-CA-LA-2019.json
US-CA-LA-2020.json
US-CT-2015.json
US-CT-2016.json
US-DC-2015.json
US-DC-2017.json
US-DC-2018.json
US-DC-2019.json
US-DC-2020.json
US-DE-2015.json
US-DE-2016.json
US-DE-2018.json
US-DE-2020.json
US-FL-2015.json
US-FL-2019.json
US-FL-2020.json
US-GA-2016.json
US-GA-2017.json
US-GA-2018.json
US-GA-2019.json
US-GA-2020.json
US-HI-2015.json
US-HI-2016.json
US-HI-2017.json
US-HI-2018.json
US-HI-2019.json
US-HI-2020.json
US-IA-2016.json
US-IL-2015.json
US-IL-2016.json
US-IL-2017.json
US-IL-2018.json
US-IL-2019.json
US-IL-2020.json
US-IN-2015.json
US-IN-2016.json
US-IN-2017.json
US-IN-2018.json
US-IN-2019.json
US-IN-2020.json
US-KY-2017.json
US-KY-2018.json
US-KY-2019.json
US-KY-2020.json
US-LA-2016.json
US-LA-2017.json
US-LA-2019.json
US-LA-NO-2015.json
US-LA-NO-2018.json
US-LA-NO-2019.json
US-MA-2015.json
US-MA-2016.json
US-MA-2017.json
US-MA-2020.json
US-ME-2015.json
US-ME-2017.json
US-ME-2018.json
US-ME-2019.json
US-ME-2020.json
US-MO-2016.json
US-MO-2017.json
US-MO-2018.json
US-MO-2019.json
US-MO-2020.json
US-MS-2015.json
US-MT-2016.json
US-MT-2017.json
US-MT-2020.json
US-NC-2017.json
US-NC-2018.json
US-NC-2019.json
US-NC-2020.json
US-NE-2015.json
US-NH-2016.json
US-NH-2020.json
US-NJ-2015.json
US-NJ-2016.json
US-NJ-2017.json
US-NJ-2018.json
US-NJ-2019.json
US-NJ-2020.json
US-NV-2016.json
US-NV-2017.json
US-NV-2018.json
US-NV-2020.json
US-NY-2015.json
US-NY-2016.json
US-NY-2017.json
US-NY-2018.json
US-NY-2019.json
US-NY-2020.json
US-SC-2016.json
US-TN-2017.json
US-TN-2018.json
US-TN-2019.json
US-TN-2020.json
US-TX-2015.json
US-TX-2016.json
US-TX-2018.json
US-TX-2019.json
US-WI-2015.json
US-WI-2016.json
US-WI-2017.json
US-WI-2018.json
US-WI-2019.json
US-WI-2020.json
US-WV-2015.json
US-WV-2016.json
US-WV-2017.json
US-WV-2018.json
US-WV-2019.json
US-WV-2020.json

get Holidays without Year

Hello, is it possible to get the Holidays without providing a year, just the data from the holidays.json?

isHoliday() returning holidays on wrong days

Hey! So I'm a little confused on how to get isHoliday() working correctly.

I know that it respects timezones but I'm still having troubles getting it to return the correct days.

Here is the code I have:

var Holidays = require('date-holidays')
var hd = new Holidays('US')
console.log(hd.isHoliday(new Date('2018-01-02 00:00:00 GMT+0000')))

// { date: '2018-01-01 00:00:00',
//   start: 2018-01-01T05:00:00.000Z,
//   end: 2018-01-02T05:00:00.000Z,
//   name: 'New Year\'s Day',
//   type: 'public' }

And as you can see it returns New Year's Day for January 2nd, however, New Year's Day is actually on January 1st, therefore it should return false.

I'm pretty sure this has something to do with timezones but is there anyway I can get holidays to only return on the actual day that they are on?

Clarify Canada mandatory public holidays

Hi, I'm from the Quebec state of Canada and I do know the "Boxing Day" (December 26th) and Remembrance Day (November 11) ARENT official holidays (as stated in by my state http://www4.gouv.qc.ca/fr/Portail/citoyens/programme-service/Pages/Info.aspx?sqctype=sujet&sqcid=329 - thought December 25th is usually paid by the employer).
There is no trace of a possible weird exception for the Quebec state. (Though I did only a quick search)

When looking for the Canada holidays I found a couple of links, even on the Canada tax web portal I found 2 pages (https://www.tpsgc-pwgsc.gc.ca/remuneration-compensation/services-paye-pay-services/paye-centre-pay/feries-holidays-eng.html and https://www.canada.ca/en/revenue-agency/services/tax/public-holidays.html), listing the Boxing Day as well as the Remembrance Day, as Canada holidays. One of these page refers to what looks like a law page.
So I'm confused even as a Canadian...

Google embedded result tools also match my state website. (Warning: On April we have a substitution day)

I do believe they could be for employees working for the Canada government and aren't public holidays.

I don't quite want to change my country file yet since I don't know per-state. If some github users from Canada could post here their holidays for their state it would be great!

issue with new years eve

Hi there, first, thanks for a great library!

We recently ran into an issue with the range for New Year's Eve showing up properly. Here's the code I'm running:

    // create a new instance of holidays for the business' country
    const holidays = new Holidays(country) // US for this example

    // set timezone for the holidays
    holidays.setTimezone(timezone) // America/Denver for this example

    // get all of the holidays for the current year
    const countryHolidays = holidays.getHolidays('2018')

When I log countryHolidays, I see the following for New Year's Eve:

{ date: '2018-12-31 18:00:00',
  start: 2019-01-01T01:00:00.000Z,
  end: 2019-01-01T07:00:00.000Z,
  name: 'New Year\'s Eve',
  type: 'observance' }

I'd expect start to be 2018-12-31T07:00:00.000Z.

Thoughts? Thanks in advance for your help!

TypeError when using with the provided Typescript Typings

Hi,
when I try to use the version 1.2.8 via typescript I am getting the following error:

> node js/index.js

/Users/asoysal/work/date-holidays-test/js/index.js:4
const h = new date_holidays_1.default();
          ^

TypeError: date_holidays_1.default is not a constructor

TS File, which I've based it on the test file in typescript folder:

import Holidays from "date-holidays"

const h = new Holidays()

generated js looks like this:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var date_holidays_1 = require("date-holidays");
var h = new date_holidays_1.default();

How to define a custom holiday?

I need to add "The day after Independence day" for one state. I think I see in the YAML where I would do it (I think). But the format looks a tad tricky to me, Independence day looks like:

07-04 and if sunday then next monday if saturday then previous friday:
        substitute: true
        _name: Independence Day

I'm guessing it would be the same except 07-05 ?

What I don't understand is how I can add that without essentially hacking the existing YAML file?

How to get working in browser

Hi,

I'm at loss, how would one get this script to work in a regular browser?
Do I really need node to get this script going or can I use it at the frontend as well?
It's suggested it is possible but how?

Aren't there some ready to grab script files I can inlcude on my page, include some locales and work with it?

CDN

Would the author consider putting this library on a CDN like cloudflare or https://cdnjs.com so that we can use sites like Codepen to prototype. Thanks in advance.

Error date-holidays-parser/src/CalEvent in ? - Expected identifier

I am getting the following error when in Internet Explorer 11.

Error date-holidays-parser/src/CalEvent in ? - Expected identifier

This is for the following line.

const {isDate} = require('./internal/utils')

My guess is it is interpreting the destructuring assignment as an object. My project is based off of react-boilerplate and is using babel-polyfill instead or core-js, not sure if that is the cause. Any ideas what could be causing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.