Skip to content

A Moment.js plugin for handling holidays at scale.

License

Notifications You must be signed in to change notification settings

nesto-software/moment-holiday

Repository files navigation

MOMENT-HOLIDAY

Handling holidays with 💪 typings using TypeScript

npm typescript docs Build Status Coverage Status Known Vulnerabilities gitter license

A Moment.js plugin for handling holidays at scale.

Another holiday library?

With date-holidays and kodie's moment-holiday, there are two alternatives to @nesto-software/moment-holiday. We want to improve the existing approaches by providing a high-performance solution for enterprise Node.js backends.

As we found out, there are a lot of challenges in providing a library which covers most business needs in the B2B sector. We face customers who want to bring in their own holidays. In order to do so, we provide database integration and a caching strategy to reduce the impact of database queries whenever possible. Click here if you are curious how we do it.

For a list of currently supported countries, click here. If your country is missing, we want to encourage you to add your locale bundle by submitting a PR.

Our main focus is on Node.js as we think that it is most effective if holidays are managed centrally and exposed through a REST API. However, there is browser support if you want to use this library in the frontend.

Features

  • 🚀 Built for Node.js and Browser
  • ⚡️️ Simple, Powerful, & Intuitive API
  • 💪 Typings using TypeScript
  • 🔥 Better Performance using Function Caching
  • 🇩🇪 🇦🇹 Multiple countries, states and regions
  • 📑 Database Support for Custom Holidays

Getting Started

Check out the Quick Start documentation to get started.

Supported Countries, States, Regions

Countries: 3
├── DE: Germany (Deutschland)
│      └── BW: Baden-Württemberg
│      ├── BY: Bayern
│      │      └── BY_AUG: Augsburg
│      │      └── BY_CATHOLIC: Überwiegend katholische Gemeinden
│      └── 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
│      │      └── SN_CATHOLIC: Überwiegend katholische Gemeinden
│      └── ST: Sachsen-Anhalt
│      └── SH: Schleswig-Holstein
│      └── TH: Thüringen
│      │      └── TH_CATHOLIC: Überwiegend katholische Gemeinden
├── SE: Sweden (Sverige) country locale only
└── AT: Austria (Österreich) country locale only

Roadmap

  1. Increase test coverage.
  2. Provide better documentation and usage examples.
  3. Encourage developers to help increasing the number of supported countries.

Usage

import moment from "moment";  // always import moment before moment-holiday (peer-dependency with side effects)
import createMomentHolidayConfiguration from "@nesto-software/moment-holiday";

// create a holiday configuration for Germany / Bavaria
const holidays = createMomentHolidayConfiguration("DE", "BY");
const holidays2018 = holidays.in(2018);

// display the holiday names and their corresponding date for 2018
console.log(holidays2018.map(holiday => holiday.name + " - " + holiday.moment.format("DD.MM.YYYY")));

For more examples, please visit the docsify examples page.

License

Copyright 2018 Nesto Software GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.