Skip to content

Commit

Permalink
Merge branch 'feat-if-holiday-rule' into norfolk-island
Browse files Browse the repository at this point in the history
  • Loading branch information
svict4 committed Jan 5, 2022
2 parents 4b93f9c + 05b9718 commit 6087aaf
Show file tree
Hide file tree
Showing 323 changed files with 2,737 additions and 63 deletions.
11 changes: 5 additions & 6 deletions data/countries/CH.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ holidays:
days:
01-01:
_name: 01-01
easter -3:
_name: easter -3
type: observance
easter -2:
_name: easter -2
easter:
Expand Down Expand Up @@ -247,15 +250,11 @@ holidays:
de: Berchtoldstag
fr: Saint-Berthold
type: optional
# TODO: needs new rule: "Thursday after 04-02 if easter -3 then next Thursday"
thursday after 04-02:
# if falls on easter -3 (Maundy Thursday) then move to next Thursday
Thursday after 04-02 if is observance holiday then next Thursday:
name:
de: Näfelser Fahrt
fr: Bataille de Näfels
disable:
- "2023-04-06"
enable:
- "2023-04-13"
3rd sunday after 09-01: false
11-01:
_name: 11-01
Expand Down
7 changes: 1 addition & 6 deletions data/countries/HK.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,11 @@ holidays:
name:
en: Hong Kong Special Administrative Region Establishment Day
zh: 香港特別行政區成立紀念日
# TODO: add rule: "chinese 08-0-15 if 07-01 then next weekday"
chinese 08-0-16 and if Sunday then next Monday:
chinese 08-0-16 and if Sunday then next Monday if is public holiday then next day omit Saturday, Sunday:
substitute: true
name:
en: The day following the Chinese Mid-Autumn Festival
zh: 中秋節翌日
disable:
- "2020-10-01"
enable:
- "2020-10-02"
10-01 and if Sunday then next Monday:
substitute: true
name:
Expand Down
5 changes: 2 additions & 3 deletions data/countries/NZ.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,10 @@ holidays:
en: Otago Province
mi: Ōtākou
days:
# TODO: needs new rule "03-23 if ... then next monday if easter 1 then next Monday"
03-23 if tuesday,wednesday,thursday then previous monday if friday,saturday,sunday then next monday:
# 03-23 if ... then next monday if easter 1 then next Monday"; This will happen in 2285 the next time ;)
03-23 if Tuesday,Wednesday,Thursday then previous Monday if Friday,Saturday,Sunday then next Monday if is public holiday then next Monday:
name:
en: Provincial anniversary day
note: varies if coincides with easter monday
STL:
names:
en: Southland
Expand Down
21 changes: 20 additions & 1 deletion docs/specification.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Specification for `holidays.yaml`

Version: 2.0.0
Version: 2.1.0

This document describes the data contained within the files `holidays.yaml` and
`names.yaml`.
Expand Down Expand Up @@ -523,6 +523,25 @@ Where:
- `09-22 if 09-21 is holiday` is September 22nd is public holiday only if September 21st is also a holiday
- `09-22 if 09-21 and 09-23 is public holiday` is September 22nd is public holiday only if September 21st and September 23rd are public holidays

### Change to different weekday if date already falls on a holiday

Rule: `<rule> if is (<type>)? holiday then (<count>)? (next|previous) <weekday>`

Rule: `<rule> if is (<type>)? holiday then (<count>)? (next|previous) day (omit <weekdays>)?`

Where:
- `<rule>` any rule
- `<type>` public, bank, school, observance, optional (defaults to public if omitted)
- `<count>` 1...31, 1st, 2nd, 3rd
- `<weekday>` Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
- `<weekdays>` Comma separated list of `<weekday>`

**Examples**:

- `Thursday after 04-02 if is observance holiday then next Thursday`
- `03-01 and if Saturday, Sunday then next Monday if is holiday then 2nd next Tuesday since 2022`
- `05-01 if is public holiday then 2nd next day omit Saturday, Sunday`

### Enabling a rule since or in certain years

> __Note:__ Use quotes around dates!
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2015.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Thu"
},
{
"date": "2015-04-02 00:00:00",
"start": "2015-04-01T22:00:00.000Z",
"end": "2015-04-02T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2015-04-03 00:00:00",
"start": "2015-04-02T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Fri"
},
{
"date": "2016-03-24 00:00:00",
"start": "2016-03-23T23:00:00.000Z",
"end": "2016-03-24T23:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2016-03-25 00:00:00",
"start": "2016-03-24T23:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2017.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Sun"
},
{
"date": "2017-04-13 00:00:00",
"start": "2017-04-12T22:00:00.000Z",
"end": "2017-04-13T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2017-04-14 00:00:00",
"start": "2017-04-13T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2018.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Mon"
},
{
"date": "2018-03-29 00:00:00",
"start": "2018-03-28T22:00:00.000Z",
"end": "2018-03-29T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2018-03-30 00:00:00",
"start": "2018-03-29T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Tue"
},
{
"date": "2019-04-18 00:00:00",
"start": "2019-04-17T22:00:00.000Z",
"end": "2019-04-18T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2019-04-19 00:00:00",
"start": "2019-04-18T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2020.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Wed"
},
{
"date": "2020-04-09 00:00:00",
"start": "2020-04-08T22:00:00.000Z",
"end": "2020-04-09T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2020-04-10 00:00:00",
"start": "2020-04-09T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2021.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Fri"
},
{
"date": "2021-04-01 00:00:00",
"start": "2021-03-31T22:00:00.000Z",
"end": "2021-04-01T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2021-04-02 00:00:00",
"start": "2021-04-01T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2022.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Sat"
},
{
"date": "2022-04-14 00:00:00",
"start": "2022-04-13T22:00:00.000Z",
"end": "2022-04-14T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2022-04-15 00:00:00",
"start": "2022-04-14T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2023.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Sun"
},
{
"date": "2023-04-06 00:00:00",
"start": "2023-04-05T22:00:00.000Z",
"end": "2023-04-06T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2023-04-07 00:00:00",
"start": "2023-04-06T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2024.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Mon"
},
{
"date": "2024-03-28 00:00:00",
"start": "2024-03-27T23:00:00.000Z",
"end": "2024-03-28T23:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2024-03-29 00:00:00",
"start": "2024-03-28T23:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-2025.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"rule": "01-01",
"_weekday": "Wed"
},
{
"date": "2025-04-17 00:00:00",
"start": "2025-04-16T22:00:00.000Z",
"end": "2025-04-17T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2025-04-18 00:00:00",
"start": "2025-04-17T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2015.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Fri"
},
{
"date": "2015-04-02 00:00:00",
"start": "2015-04-01T22:00:00.000Z",
"end": "2015-04-02T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2015-04-03 00:00:00",
"start": "2015-04-02T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2016.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Sat"
},
{
"date": "2016-03-24 00:00:00",
"start": "2016-03-23T23:00:00.000Z",
"end": "2016-03-24T23:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2016-03-25 00:00:00",
"start": "2016-03-24T23:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2017.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Mon"
},
{
"date": "2017-04-13 00:00:00",
"start": "2017-04-12T22:00:00.000Z",
"end": "2017-04-13T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2017-04-14 00:00:00",
"start": "2017-04-13T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2018.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Tue"
},
{
"date": "2018-03-29 00:00:00",
"start": "2018-03-28T22:00:00.000Z",
"end": "2018-03-29T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2018-03-30 00:00:00",
"start": "2018-03-29T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2019.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Wed"
},
{
"date": "2019-04-18 00:00:00",
"start": "2019-04-17T22:00:00.000Z",
"end": "2019-04-18T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2019-04-19 00:00:00",
"start": "2019-04-18T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2020.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Thu"
},
{
"date": "2020-04-09 00:00:00",
"start": "2020-04-08T22:00:00.000Z",
"end": "2020-04-09T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2020-04-10 00:00:00",
"start": "2020-04-09T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2021.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Sat"
},
{
"date": "2021-04-01 00:00:00",
"start": "2021-03-31T22:00:00.000Z",
"end": "2021-04-01T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2021-04-02 00:00:00",
"start": "2021-04-01T22:00:00.000Z",
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/CH-AG-2022.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"rule": "01-02",
"_weekday": "Sun"
},
{
"date": "2022-04-14 00:00:00",
"start": "2022-04-13T22:00:00.000Z",
"end": "2022-04-14T22:00:00.000Z",
"name": "Gründonnerstag",
"type": "observance",
"rule": "easter -3",
"_weekday": "Thu"
},
{
"date": "2022-04-15 00:00:00",
"start": "2022-04-14T22:00:00.000Z",
Expand Down
Loading

0 comments on commit 6087aaf

Please sign in to comment.