Document example holidays

master
Wuzzy 2020-08-28 14:36:09 +02:00
parent 2860f72b8f
commit 26f8f5c36d
1 changed files with 22 additions and 0 deletions

22
API.md
View File

@ -102,6 +102,28 @@ Holidays can be queried with `calendar.get_holidays`.
return true if it's a holiday and false if not.
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)`
Returns table of all holidays for the given day.