Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions docs/api/calendar.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
title: "calendar"
description: "Calendar and date helpers."
---

# `calendar`

Calendar and date helpers.

> [!WARNING]
Expand Down Expand Up @@ -56,7 +55,7 @@ Return the default first weekday.

**Return**:

- `firstweekday` (`1|2|3|4|5|6|7`)
- `firstweekday` (`modsCalendarWeekday`)

**Example**:

Expand All @@ -77,7 +76,7 @@ Set the default first weekday.

**Parameters**:

- `firstweekday` (`1|2|3|4|5|6|7`)
- `firstweekday` (`modsCalendarWeekday`)

**Example**:

Expand Down Expand Up @@ -148,7 +147,7 @@ Return the first weekday and number of days for a month.

**Return**:

- `weekday` (`1|2|3|4|5|6|7`)
- `weekday` (`modsCalendarWeekday`)
- `ndays` (`integer`)

**Example**:
Expand All @@ -168,13 +167,12 @@ Return weekday number where Monday is `1` and Sunday is `7`.
**Parameters**:

- `year` (`integer`)
- `month` (`1|2|3|4|5|6|7|8|9|10|11|12`)
- `day`
(`1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31`)
- `month` (`modsCalendarMonth`)
- `day` (`modsCalendarMonthday`)

**Return**:

- `weekday` (`1|2|3|4|5|6|7`)
- `weekday` (`modsCalendarWeekday`)

**Example**:

Expand All @@ -194,7 +192,7 @@ Return the formatted weekday header string.
**Parameters**:

- `width?` (`integer`)
- `firstweekday?` (`1|2|3|4|5|6|7`)
- `firstweekday?` (`modsCalendarWeekday`)

**Return**:

Expand All @@ -221,8 +219,8 @@ Iterate `(year, month, day, weekday)` tuples for a full calendar grid.
**Parameters**:

- `year` (`integer`)
- `month` (`1|2|3|4|5|6|7|8|9|10|11|12`)
- `firstweekday?` (`1|2|3|4|5|6|7`)
- `month` (`modsCalendarMonth`)
- `firstweekday?` (`modsCalendarWeekday`)

**Return**:

Expand Down Expand Up @@ -269,7 +267,7 @@ Iterate weekday numbers for one full week.

**Parameters**:

- `firstweekday?` (`1|2|3|4|5|6|7`)
- `firstweekday?` (`modsCalendarWeekday`)

**Return**:

Expand All @@ -290,7 +288,7 @@ print(table.concat(weekdays, ", ")) --> "1, 2, 3, 4, 5, 6, 7"

<a id="days"></a>

### `days` (`mods.List<string>`)
### `days` ([`mods.List`]`<string>`)

Weekday names indexed from `1` (Monday) to `7` (Sunday).

Expand All @@ -301,7 +299,7 @@ print(cal.days[7]) --> Sunday

<a id="firstweekday"></a>

### `firstweekday` (`1|2|3|4|5|6|7`)
### `firstweekday` (`modsCalendarWeekday`)

The default first weekday field.

Expand All @@ -318,11 +316,17 @@ print(cal.firstweekday) --> 7

<a id="months"></a>

### `months` (`mods.List<string>`)
### `months` ([`mods.List`]`<string>`)

Month names indexed from `1` to `12`.

```lua
print(cal.months[1]) --> January
print(cal.months[12]) --> December
```

<!-- markdownlint-disable MD053 -->
<!-- prettier-ignore-start -->
[`mods.List`]: /mods/api/list.html
<!-- prettier-ignore-end -->
<!-- markdownlint-enable MD053 -->
Loading