
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
moment-feiertage
Advanced tools
Moment.js Plugin for german holidays; check if a given Date is a german holiday
moment-feiertage is a Moment.js plugin to determine if a date is a german holiday. Holidays are taken from Wikipedia (de). Feel free to contribute!
npm install moment-feiertage --save. Moment.js is a peer dependency, so don't forget to install it, if you haven't already.moment from moment-feiertage like you would from the original Moment.js package. moment-feiertage exports the original moment object with extended functionality.// Typescript
import * as moment from 'moment-feiertage';
// node
const moment = require('moment-feiertage');
since 2.0.0
const codes = moment.getAllStateCodes();
/* returns ['BW','BY','BE','BB','HB','HH','HE','MV','NI','NW','RP','SL','SN','ST','SH','TH']*/
since 2.0.0
Returns an object containing all holidays of a year. Every holiday has a date and a state property. date is holding a moment object representing the holidays date. It's a nationwide holiday, if the state value is an empty Array.
const codes = moment.getHolidaysByYear(2020);
/* returns {
'Neujahrstag': {
date: moment('2020-01-01'),
state: [] // nationwide holiday
},
'Heilige Drei Könige': {
date: moment('2020-01-06')
state: ['BW', 'BY', 'ST'] // only these states celebrate
},
[ ... ]
} */
since 1.1.0
From version 1.1.0 on isHoliday() supports Arrays. Pass an empty Array to test against all states, or pass an Array of state codes (e.g. ['BY', 'SH']). The return value is an Object:
{
allStates: boolean, // default false
holidayName: string, // default: ''
holidayStates: Array<string>, // default: []
testedStates: Array<string> // default: ...allStates
}
allStates is true, if the checked date is a nationwide holiday, even if not all states are checked because of the states param.holidayName contains the name of the holidayholidayStates contains the states, where this holiday is celebrated. If states param is provided, holidayStates contains only a subset of statestestedStates is the same as the states param. If states param is [], isHoliday will check against all states by defaultconst christmasInAllStates = moment('2018-11-01').isHoliday([]);
/* returns {
allStates: true,
holidayName: '1. Weihnachtsfeiertag',
holidayStates: ...allStates,
testedStates: ...allStates
}*/
const christmasInSomeStates = moment('2018-11-01').isHoliday(['BW', 'SH']);
/* returns {
allStates: true,
holidayName: '1. Weihnachtsfeiertag',
holidayStates: [ 'BW', 'SH' ],
testedStates: [ 'BW', 'SH' ]
}*/
const someDateInAllStates = moment('2018-11-01').isHoliday([]);
/* returns {
allStates: false,
holidayName: 'Allerheiligen',
holidayStates: [ 'BW', 'BY', 'NW', 'RP', 'SL' ],
testedStates: ...allStates
}*/
const noHolidayDateInAllStates = moment('2018-12-12').isHoliday([]);
/* returns {
allStates: false,
holidayName: '',
holidayStates: [],
testedStates: ...allStates
}*/
since 1.0.0
Since version 1.0.0 isHoliday() checks if there's a holiday at a moment object. A state code can be provided optionally.
const nowIsHoliday = moment().isHoliday();
// returns name of holiday (string) if date is a holiday
// retruns false (boolean) if date is not a holiday
const someDateIsHoliday = moment('2019-12-25').isHoliday();
// returns '1. Weihnachtsfeiertag' - is a holiday in all states
const isHolidayInAllStates = moment('2017-08-15').isHoliday();
// returns false - is not a holiday in all states
const isHolidayInBavaria = moment('2017-08-15').isHoliday('BY');
// returns false - is not a holiday in BY
const isHolidayInSaarland = moment('2017-08-15').isHoliday('SL');
// returns 'Mariä Himmelfahrt' - is a holiday in SL
BW = Baden-WĂĽrttemberg
BY = Bayern
BE = Berlin
BB = Brandenburg
HB = Bremen
HH = Hamburg
HE = Hessen
MV = Mecklenburg-Vorpommern
NI = Niedersachsen
NW = Nordrhein-Westfalen
RP = Rheinland-Pfalz
SL = Saarland
SN = Sachsen
ST = Sachsen-Anhalt
SH = Schleswig-Holstein
TH = ThĂĽringen
npm install and add your desired version of Moment.js: npm install moment --no-savenpm run build: linting, formating, building, testingFAQs
Moment.js Plugin for german holidays; check if a given Date is a german holiday
We found that moment-feiertage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.