You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-tos/define-holidays.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,21 +36,22 @@ The Holidata library provides a set of _date functions_ to handle the different
36
36
The `date` function can be used for holidays taking place on a fixed date (_n-th day of a month_), e.g.:
37
37
38
38
```python
39
-
date(month=1, day=1) # January 1st
40
-
date(month=12, day=25) # December 25th
39
+
date(Month.JANUARY, 1) # January 1st
40
+
date(Month.DECEMBER, 25) # December 25th
41
41
```
42
42
43
43
### Weekday Occurrences
44
44
45
45
For holidays which take place on a certain weekday of a month, there are the functions `first`, `second`, `third`, `fourth`, and `last` to handle those cases, e.g.:
46
+
46
47
```python
47
48
# n-th occurrence of a weekday in a month
48
-
first("monday").of("may")
49
-
second("tuesday").of("june")
50
-
third("wednesday").of("july")
51
-
fourth("thursday").of("august")
49
+
first(Weekday.MONDAY).of(Month.MAY)
50
+
second(Weekday.TUESDAY).of(Month.JUNE)
51
+
third(Weekday.WEDNESDAY).of(Month.JULY)
52
+
fourth(Weekday.THURSDAY).of(Month.AUGUST)
52
53
53
-
last("friday").of("september")
54
+
last(Weekday.FRIDAY).of(Month.SEPTEMBER)
54
55
```
55
56
56
57
### Easter-Based Dates
@@ -82,14 +83,14 @@ day(2).before(<date_function>) # 2 days before
82
83
day(1).after(<date_function>) # 1 day after
83
84
84
85
# Weekday before/after a date
85
-
first("monday").before(<date_function>)
86
-
second("tuesday").after(<date_function>)
86
+
first(Weekday.MONDAY).before(<date_function>)
87
+
second(Weekday.TUESDAY).after(<date_function>)
87
88
```
88
89
89
90
Those calls can be nested. An example for this would be the German holiday _Buß- und Bettag_ which takes place on the 11th day before the first Advent Sunday, which is the fourth sunday before Christmas:
0 commit comments