Skip to main content

format_datetime

Function format_datetime 

Source
pub fn format_datetime(
    dt: &RosettaDateTime,
    fmt: &str,
    lang: Option<&LanguageData>,
) -> String
Expand description

Format a RosettaDateTime using a strftime-style format string.

Supported specifiers:

  • %Y — 4-digit year
  • %m — 2-digit month (01–12)
  • %d — 2-digit day (01–31)
  • %H — 2-digit hour in 24h (00–23)
  • %M — 2-digit minute (00–59)
  • %S — 2-digit second (00–59)
  • %z — UTC offset (+0800)
  • %Z — UTC offset with colon (+08:00)
  • %A — Full weekday name (from language data, or English default)
  • %a — Abbreviated weekday name
  • %B — Full month name
  • %b — Abbreviated month name
  • %p — AM/PM
  • %% — Literal %