Skip to content

fmt-date

let fmt-date(
  dt,
  locale: "en",
  length: "full"
)

Formats a date in some locale. Dates are assumed to be ISO dates.

Arguments

dt

The date to format. This can be a datetime or a dictionary with year, month, day.

Example

#fmt-date(datetime(
    year: 2024,
    month: 5,
    day: 31,
)) \
#fmt-date(( // (1)!
    year: 2020,
    month: 8,
    day: 14,
), locale: "fr")

  1. Date passed as a dictionary

PreviewPreview

locale

The locale to use when formatting the date. A Unicode Locale Identifier. Notably, this can be used to set the calendar by setting ca to a bcp47 calendar name.

Example

#let date = datetime(
  year: 2024,
  month: 5,
  day: 31,
)

#set enum(start: 8)
+ #fmt-date(date, locale: "en")
+ #fmt-date(date, locale: "ka")
+ #fmt-date(date, locale: "en-u-ca-buddhist")
+ #fmt-date(date, locale: "en-u-ca-chinese")
+ #fmt-date(date, locale: "en-u-ca-coptic")
+ #fmt-date(date, locale: "en-u-ca-dangi")
+ #fmt-date(date, locale: "en-u-ca-ethioaa")
+ #fmt-date(date, locale: "en-u-ca-hebrew")
+ #fmt-date(date, locale: "en-u-ca-indian")
+ #fmt-date(date, locale: "en-u-ca-islamic")
+ #fmt-date(date, locale: "en-u-ca-iso8601")
+ #fmt-date(date, locale: "en-u-ca-japanese")
+ #fmt-date(date, locale: "en-u-ca-persian")
+ #fmt-date(date, locale: "en-u-ca-roc")

PreviewPreview

length

The length of the formatted date ("full" (default), "long", "medium", or "short").

Example

#let date = datetime(
  year: 2024,
  month: 5,
  day: 31,
)

*Full*
- #fmt-date(date, length: "full")
- #fmt-date(date, length: "full", locale: "is")
- #fmt-date(date, length: "full", locale: "hi")

*Long*
- #fmt-date(date, length: "long")
- #fmt-date(date, length: "long", locale: "lo")
- #fmt-date(date, length: "long", locale: "pt")

*Medium*
- #fmt-date(date, length: "medium")
- #fmt-date(date, length: "medium", locale: "mn")
- #fmt-date(date, length: "medium", locale: "hy")

*Short*
- #fmt-date(date, length: "short")
- #fmt-date(date, length: "short", locale: "es")
- #fmt-date(date, length: "short", locale: "sk")

PreviewPreview