#holidays #calendar #business #exchange #day-week

cal-calc

Simple tool for calculating holidays based on a set of holiday rules

5 releases

0.2.0 Feb 24, 2023
0.1.3 Jun 21, 2022
0.1.2 Apr 20, 2022
0.1.1 Apr 18, 2022
0.1.0 Apr 18, 2022

#344 in Date and time

Download history 25/week @ 2023-12-03 33/week @ 2023-12-10 8/week @ 2023-12-17 20/week @ 2023-12-24 9/week @ 2023-12-31 7/week @ 2024-01-07 14/week @ 2024-01-14 9/week @ 2024-01-21 15/week @ 2024-01-28 14/week @ 2024-02-04 11/week @ 2024-02-18 20/week @ 2024-02-25 25/week @ 2024-03-03 6/week @ 2024-03-10 21/week @ 2024-03-17

73 downloads per month
Used in finql

MIT/Apache

36KB
893 lines

cal-calc

Purpose of this library is to provide a tool for calculating holidays for a given time period based on a set of rules.

The following rules are supported:

  • Week day: any day of week (e.g. Sunday)
  • Yearly days: same date every year
  • Moveable yearly days: as yearly days, but moved to the next non-weekend day if it falls on a weekday
  • Modified movable yearly days: Move to Friday if it falls on Saturday and to Monday if it falls on Sunday
  • Single day: special holiday valid only in one year
  • Easter offset: day that is calculated relative to Easter sunday
  • Month week day: nth weekday of a given month

Examples

uk_settlement_calendar

This examples demonstrates using the library to calculate the UK settlement calendar, which is particular interesting because of its complex holiday rules, e.g. last Monday of August (Summer bank holiday), fixed day holidays that are moved to the next working day if the holiday falls on a weekend, or singular holidays which are not repeated every year, but celebrate unique events like a royal wedding.

Dependencies

~1.1–1.8MB
~38K SLoC