tempo/month

Functions to use with the Month type in Tempo.

Constants

pub const months: List(Month)

An ordered list of all months in the year. -> [Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]

Functions

pub fn days(of month: Month, in year: Int) -> Int

Returns the number of days in a month.

Example

date.literal("2024-06-13")
|> date.get_month
|> month.days
// -> 30
date.literal("2024-12-03")
|> date.get_month
|> month.days
// -> 31
pub fn from_int(month: Int) -> Result(Month, Nil)

Gets a month from an integer representing the order of the month on the civil calendar.

Example

month.from_int(6)
// -> Ok(tempo.Jun)
month.from_int(13)
// -> Error(Nil)
pub fn from_long_string(month: String) -> Result(Month, Nil)

Gets a month from a long month string.

Example

month.from_long_string("June")
// -> Ok(tempo.Jun)
month.from_long_string("Jun")
// -> Error(Nil)
pub fn from_short_string(month: String) -> Result(Month, Nil)

Gets a month from a short month string.

Example

month.from_short_string("Jun")
// -> Ok(tempo.Jun)
month.from_short_string("June")
// -> Error(Nil)
pub fn from_string(month: String) -> Result(Month, Nil)

Gets a month from a month string.

Example

month.from_string("Jun")
// -> Ok(tempo.Jun)
month.from_string("June")
// -> Ok(tempo.Jun)
month.from_string("Hello")
// -> Error(Nil)
pub fn to_int(month: Month) -> Int

Returns a month’s number on the civil calendar.

Example

date.literal("2024-06-13")
|> date.get_month
|> month.to_int
// -> 6
pub fn to_long_string(month: Month) -> String

Returns a month’s long name.

Example

date.literal("2024-06-13")
|> date.get_month
|> month.to_short_string
// -> "June"
pub fn to_short_string(month: Month) -> String

Returns a month’s short name.

Example

date.literal("2024-06-13")
|> date.get_month
|> month.to_short_string
// -> "Jun"
Search Document