ISO 8601 weeks: weeks start on Monday, and week 1 of a year is the week
that holds the year's first Thursday. A week is written 2027-W11.
The week picker posts weeks in this form, and Koyomi.Week stores the
Monday of the week in a :date column.
Summary
Functions
Reads YYYY-Www (or YYYYWww) into the Monday of the week.
The Monday of an ISO week, or :error when the year has no such week.
Writes the week of a day as YYYY-Www.
The ISO year and week number of a day.
The number of ISO weeks of a year: 52 or 53.
Functions
Reads YYYY-Www (or YYYYWww) into the Monday of the week.
Examples
iex> Koyomi.ISOWeek.from_iso8601("2027-W11")
{:ok, ~D[2027-03-15]}
iex> Koyomi.ISOWeek.from_iso8601("2027-W54")
:error
The Monday of an ISO week, or :error when the year has no such week.
Examples
iex> Koyomi.ISOWeek.monday(2026, 53)
{:ok, ~D[2026-12-28]}
iex> Koyomi.ISOWeek.monday(2027, 53)
:error
Writes the week of a day as YYYY-Www.
Examples
iex> Koyomi.ISOWeek.to_iso8601(~D[2027-03-17])
"2027-W11"
The ISO year and week number of a day.
Examples
iex> Koyomi.ISOWeek.week(~D[2027-01-01])
{2026, 53}
iex> Koyomi.ISOWeek.week(~D[2027-03-15])
{2027, 11}
@spec weeks_in_year(integer()) :: 52 | 53
The number of ISO weeks of a year: 52 or 53.
Examples
iex> Koyomi.ISOWeek.weeks_in_year(2026)
53