Month

:= [Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]

The Month module provides the Month type, representing one of the twelve calendar months.

A Month is always valid, so functions that take a Month never need to handle an out-of-range value. Use from_u8 to validate a number at the boundary of your program, and to_u8 to get the number back for display or storage.

Month := [Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
is_eq : _

Are two Months equal?

to_hash : _

Hash a Month, so it can be used as a Dict key or Set element.

is_lt : Month, Month -> Bool

Does the first Month come earlier in the year than the second? Backs the < operator.

is_gt : Month, Month -> Bool

Does the first Month come later in the year than the second? Backs the > operator.

is_lte : Month, Month -> Bool

Does the first Month come earlier in the year than, or equal, the second? Backs the <= operator.

is_gte : Month, Month -> Bool

Does the first Month come later in the year than, or equal, the second? Backs the >= operator.

order_relative_to : Month, Month -> [Before, Same, After]

Compare two Months by calendar order. Lets List.sort work on a List(Month).

min : Month, Month -> Month

The earlier of two Months. Lets List.min work on a List(Month).

max : Month, Month -> Month

The later of two Months. Lets List.max work on a List(Month).

all : List(Month)

All twelve months, in calendar order.

days : Month, { is_leap : Bool } -> U8

The number of days in the month. February has 29 days when is_leap is true.

from_u8 : U8 -> Try(Month, [InvalidMonth])

Convert a month number (1 = January, 12 = December) to a Month.

from_quote : Str -> Try(Month, [BadQuotedBytes(Str)])

Let a string literal be used where a Month is expected. Both the three-letter abbreviation and the full English name are accepted.

start : Month
start = "March"

An invalid literal is a compile-time error.

next : Month -> Month

The month after this one. December wraps around to January.

prev : Month -> Month

The month before this one. January wraps around to December.

to_u8 : Month -> U8

Convert a Month to its month number (1 = January, 12 = December).