HolidayEx (holiday_ex v1.0.0)
Copy MarkdownHolidayEx is a library for checking whether a date falls within a publicly observed holiday.
This module is meant as a replacement for the Holiday library written by CoderDenis. A lot of credit goes to him and his library which serves as a baseline for this. Instead of messing around with genservers and applications we dynamically load locales at compile time, meaning we don't waste anyones memory, and the footprint stays as small as possible.
Usage
To use this module you create your own holiday module with the specific locales you intend to use. This dynamically loads the locale modules at compile time so that you don't get any more than you actually need.
defmodule MyApp.Holiday do
use HolidayEx, locales: [:no, :de, :gb]
endAlternatively you can load all the locales.
defmodule MyApp.Holiday do
use HolidayEx, locales: :all
endDependency philosophy
This library has zero dependencies, meaning as long as you understand the code you can be 100% sure that this is the only code that will run inside your program.
Extensions/bugs
This library is in low-maintance mode. If you have a specific locale with some requirements that may or may not exist you have three options:
- Submit an issue. If the fix or extension is small
- Submit a pull request. I highly encourage this.
- Fork the repository. I also highly encourage this, since the library is realtively simple and small (essentially just data)
Disclaimer
Keep in mind that this library is forward looking in time, meaning we provide no guarantees for holidays that may have existed in the past.
Summary
Functions
The Holiday.holiday? function takes a date, and a loaded locale as an atom and
produces a boolean of whether the date is a publicly observed holiday or not.
The Holiday.holiday_name function takes a date, and a loaded locale as an atom and
produces a string with the holiday name or nil if the date is not a holiday .
Types
Functions
The Holiday.holiday? function takes a date, and a loaded locale as an atom and
produces a boolean of whether the date is a publicly observed holiday or not.
(This function raises if the locale is not loaded properly)
Examples
iex> HolidayEx.holiday?(~D[2026-01-01], :no)
true
iex> HolidayEx.holiday?(~D[2026-02-01], :no)
false
The Holiday.holiday_name function takes a date, and a loaded locale as an atom and
produces a string with the holiday name or nil if the date is not a holiday .
(This function raises if the locale is not loaded properly)
Examples
iex> HolidayEx.holiday_name(~D[2026-12-24], :no)
"Julaften"
iex> HolidayEx.holiday_name(~D[2026-02-01], :no)
nil