How to generate a custom jar with your own holidays
- Create
.hol
files incalendars/
- See file format below, and examples in
examples/
- Names that start with
WEEKEND
are reserved and cannot be used
- See file format below, and examples in
- Run
gen-lib.sh
- Your jar file will be in
generated/{{lib-name}}.jar
Files with the .hol
extension specify holidays and have the .hol
extension. Each holiday occupies one line, and is
formatted like so:
Holiday name|Holiday calculation rule|modifier(s)
You can use any of the calculation rules demonstrated below. Modifiers are optional.
To add a holiday that repeats every year on the same date, use the format DDMMM
Juneteenth|19Jun
This will repeat every year on June 19th
NOTE: If you include a holiday on the 29th of February, it's only going to appear on leap years
Accepted modifiers for yearly holidays are:
Modifier | Meaning | Example |
---|---|---|
YYYY-> | Generate holiday only on and after year YYYY | New Year|01Jan|2014-> |
->YYYY | Generate holiday only before and on year YYYY | New Year|01Jan|->2014 |
observed | Holiday will be Friday/Monday if date falls on a Saturday/Sunday respectively | Independence Day|4Jul|observed |
observed-monday | Holiday will be Monday if date falls on a Saturday or Sunday | New Year's Day|1Jan|observed-monday |
observed-monday-tuesday | Holiday will be Monday/Tuesday if date falls on a Saturday/Sunday respectively | Boxing Day|26Dec|observed-monday-tuesday |
To include as a holiday a day that does not repeat every year, use the format DDMMMYYYY
Queen Elizabeth's Funeral Day|19Sep2022
Will occur on the 19th of September of the year 2022 and no other year or date
No modifiers are accepted for specific date holidays
To exclude a date that would otherwise have been generated, use a minus sign (-
) at the end
Spring Bank Holiday Moved For Jubilee Long Weekend|30May2022-
This date will be excluded
No modifiers are accepted for specific date exceptions
To specify a holiday based on an 'n-th day of the week' rule, use the format <N><Day of Week><Month>
President's Day|3MonFeb
That is, the third (3
) Monday (Mon
) of February (Feb
). Use common three-letter abbreviations for days of the week
and months.
Note that you may also specify "last" with -1
, "next-to-last" with -2
and so on. For example:
Memorial Day|-1MonMay
will generate a holiday on the last Monday of May every year
Accepted modifiers for nth day of the week holidays are:
Modifier | Meaning | Example |
---|---|---|
YYYY-> | Generate holiday only on and after year YYYY | Memorial Day|-1MonMay|2018-> |
->YYYY | Generate holiday only before and on year YYYY | Memorial Day|-1MonMay|->2018 |
To generate a holiday based on a calculation, use the format <EXPRESSION><OPERATOR><AMOUNT>
Where EXPRESSION
is one of the supported expressions below. OPERATOR
is whether +
or -
, and AMOUNT
is a
positive decimal integer.
Corpus Christi|E+60
Will calculate a date based on expression E
, and add 60 calendar days to it. If you want EXPRESSION
with no changes,
use +0
.
Expression | Meaning |
---|---|
E | Calculate the date of easter |
Accepted modifiers for expression holidays are:
Modifier | Meaning | Example |
---|---|---|
YYYY-> | Generate holiday only on and after year YYYY | Easter|E+0|2014-> |
->YYYY | Generate holiday only before and on year YYYY | Easter|E+0|->2016 |
observed | Holiday will be Friday/Monday if date falls on a Saturday/Sunday respectively | Easter On Monday|E+0|observed |
observed-monday | Holiday will be Monday if date falls on a Saturday or Sunday | Easter On Monday|E-1|observed-monday |
observed-monday-tuesday | Holiday will be Monday/Tuesday if date falls on a Saturday/Sunday respectively | Easter On Tuesday|E+0|observed-monday-tuesday |
You may add a single comment line at the very top of your holiday calendar file. It must start with a semicolon ;
; My awesome holiday file
#include BOOGALOO
Holiday Part 1|E+0
This line gets ignored by the holiday generator
You may include another calendar file in your holiday file. This is useful for example for national vs municipal holidays.
#include INCLUDED-FILE
A holiday in addition to the ones included|5May
- Remember not to write the
.hol
extension in the#include
directive. - The directive must be on the first line (only a comment may come before it).
- If you want to reference a top level calendar, use
#include CALENDAR
. To reference a calendar in a sub-folder, use#include foo/CALENDAR
. These are always absolute paths, no matter where your calendar file is located. - Only one include per file is allowed, but you may nest includes.