datebook/weekday
The day of the week.
Types
Values
pub fn days_since(day: Weekday, since: Weekday) -> Int
Returns the number of days elapsed between since and day in a 0..=6 range.
You can use this function to map a weekday to a number based on the first day of the week in a given region (e.g. Monday for Europe, Sunday for the US, Saturday for Afghanistan).
Examples
Monday |> days_since(Monday)
// -> 0
Sunday |> days_since(Tuesday)
// -> 5
Wednesday |> days_since(Sunday)
// -> 3
pub fn from_date(date: calendar.Date) -> Weekday
Returns the Weekday for a given Date.
Examples
from_date(calendar.Date(1970, calendar.January, 1))
// -> Thursday
pub fn from_days_since(days: Int, start: Weekday) -> Weekday
Returns the weekday corresponding to the number of days since start.
If days is not between 0 and 6, it will wrap around modulo 7.
Examples
2 |> from_days_since(Monday)
// -> Wednesday
-1 |> from_days_since(Sunday)
// -> Saturday
0 |> from_days_since(Thursday)
// -> Thursday
7 |> from_days_since(Tuesday)
// -> Tuesday
pub fn next(weekday: Weekday) -> Weekday
Returns the next Weekday for the given Weekday.
Examples
next(Tuesday)
// -> Wednesday