date-holidays-parser is a JavaScript and TypeScript library designed to parse and calculate worldwide holidays, acting as the rule-engine backbone for the `date-holidays` library. It provides functionalities to determine public, bank, and observance holidays for various countries, states, and regions, adhering to ISO 3166-2 standards. The library is currently at version 3.4.7 and appears to be actively maintained, though no explicit release cadence is stated. Key features include timezone consideration for holiday checks, support for substitute days, multi-language holiday names, and the ability to define custom holidays. It also uniquely integrates support for Islamic, Hebrew, and Chinese calendars, though it cautions about potential inaccuracies with Islamic dates due to moon sighting dependencies. This parser is distinct in its use of a custom grammar for day calculations, enabling precise and flexible holiday determination across diverse cultural and legal frameworks.
npm install date-holidays-parserVerified import paths — ran on the pinned version, not inferred.
Initializes the Holidays parser with global data, sets a specific locale (US, LA, NO), retrieves holidays for a year, and checks specific dates for holiday status, demonstrating timezone awareness and language setting.
Install `date-holidays` (`npm install date-holidays`) and import the data using `import holidayData from 'date-holidays/data/holidays.json';` before initializing `Holidays`.
Upgrade your Node.js environment to version 12.0.0 or greater.
For critical applications requiring precise Islamic dates, manual verification or consultation with authoritative sources is recommended as algorithmic calculations provide an approximation.
Construct `Date` objects using ISO 8601 strings with explicit timezone offsets (e.g., `new Date('YYYY-MM-DDTHH:mm:ss-05:00')`) or use UTC constructors, and be mindful of your environment's default `Date` object behavior.Convert `require('date-holidays-parser')` to `import Holidays from 'date-holidays-parser';` and `require('date-holidays/data/holidays.json')` to `import holidayData from 'date-holidays/data/holidays.json';`.Ensure `date-holidays` is installed (`npm install date-holidays`) and that `import holidayData from 'date-holidays/data/holidays.json';` is correctly loading the data before passing it to `new Holidays(holidayData)`.
Verify that `hd.init('COUNTRY', 'STATE', 'REGION')` is called with correct ISO 3166-2 codes. Use methods like `hd.getCountries()`, `hd.getStates(country)`, or `hd.getRegions(country, state)` to confirm supported locales and their exact codes.