On this page:
Format
Format.rfc2822
Format.rfc3339
Format.iso8601
Format.american
Format.european
Format.julian
Time  Format
Time  Format.minutes
Time  Format.seconds
Time  Format.milliseconds
Time  Format.microseconds
Time  Format.nanoseconds
Time  Format.auto_  subminutes
Time  Format.auto_  subseconds
Time  Zone  Format
Time  Zone  Format.offset
is_  leap_  year
days_  in_  year
days_  in_  month
year_  day
week_  day

14.7.5 Date Formats and Utilities🔗ℹ

enumeration

enum date.Format:

  rfc2822

  rfc3339

  iso8601

  american

  european

  julian

A format supported by date.Date.to_string, date.DateTime.to_string, and date.ZonedDateTime.to_string:

  • #'rfc2822: follows RFC 2822.

  • #'rfc3339: follows RFC 3339, specifically using a space character between a date and time, and showing a time zone offset (if requested) as Z, +HH:MM or +HH:MM.

  • #'iso8601: follows ISO 8601, showing a time zone offset (if requested) as Z, +HH:MM, or +HH:MM.

  • #'american: shows a date in an English, human-readable form that spells out a month and day of the week, putting the month before the day.

  • #'european: shows a date in an English, human-readable form that spells out a month and day of the week, putting the date before the month.

  • #'julian: shows the date in Julian form.

A time format that selects the smallest time granularity to be shown, sometimes used as maybe(date.TimeZoneFormat) so that #false means that a time is not shown.

  • #'minutes: Produces HH:MM

  • #'seconds: Produces HH:MM:SS

  • #'milliseconds: Produces HH:MM:SS.SSS

  • #'microseconds: Produces HH:MM:SS.SSSSSS

  • #'nanoseconds: Produces HH:MM:SS.SSSSSSSSS

  • #'auto_subminutes: The same as #'minutes if seconds and nanoseconds are zero, the same as #'auto_subseconds otherwise.

  • #'auto_subseconds: The same as #'seconds if nanoseconds are zero, and otherwise the same as #'milliseconds, #'microseconds, or #'nanoseconds depending on the number of trailing zeros available to be omitted.

enumeration

enum date.TimeZoneFormat:

  offset

A time-zone format. Although only one format is currently supported, this annotation is used as maybe(date.TimeZoneFormat) so that #false means that a time zone is not shown.

function

fun date.is_leap_year(year :: Int) :: Boolean

 

function

fun date.days_in_year(year :: Int) :~ Int.in(365 ..= 366)

Reports whether a year is a leap year or whether it has 365 or 366 days.

function

fun date.days_in_month(year :: Int,

                       month :: Int.in(1 ..= 12)) :: Int.in(28 ..= 31)

Returns the number of days in a given month during a specific year.

function

fun date.year_day(

  year :: Int,

  month :: Int.in(1 ..= 12),

  day :: Int.in(1 ..= date.days_in_month(year, month))

) :: Int.in(0 ..= 365)

Reports the index of a given day for a specific month within a specific year.

function

fun date.week_day(

  year :: Int,

  month :: Int.in(1 ..= 12),

  day :: Int.in(1 ..= date.days_in_month(year, month))

) :: Int.in(0 ..= 6)

Reports the index of a day of the week for a given day of a specific month within a specific year.