Document example holidays
parent
2860f72b8f
commit
26f8f5c36d
22
API.md
22
API.md
|
@ -102,6 +102,28 @@ Holidays can be queried with `calendar.get_holidays`.
|
||||||
return true if it's a holiday and false if not.
|
return true if it's a holiday and false if not.
|
||||||
Try to keep your calculations as simple as possible
|
Try to keep your calculations as simple as possible
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
```
|
||||||
|
-- First day of every year
|
||||||
|
calendar.register_holiday({
|
||||||
|
name = "New Year's Eve",
|
||||||
|
type = "monthday",
|
||||||
|
days = 0,
|
||||||
|
months = 0
|
||||||
|
})
|
||||||
|
|
||||||
|
-- First Sunday in May
|
||||||
|
calendar.register_holiday({
|
||||||
|
name = "Mother's Day",
|
||||||
|
type = "custom",
|
||||||
|
is_holiday = function(total_days)
|
||||||
|
local d, m, y = calendar.get_date(total_days)
|
||||||
|
local wday = calendar.get_weekday(total_days)
|
||||||
|
return wday == 6 and m == 4 and d <= 6
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### `calendar.get_holidays(total_days)`
|
### `calendar.get_holidays(total_days)`
|
||||||
Returns table of all holidays for the given day.
|
Returns table of all holidays for the given day.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue