Skip to Content

ldml

The Unicode LDML (UTS #35) date-field grammar. Imported from rosetta-date/dialects:

import { ldml } from 'rosetta-date/dialects'

Tokens

Each token and the canonical field it maps to. For how these compare across dialects, see Token Mapping.

MeaningToken
Era, abbreviatedGGG
Era, wideGGGG
Era, narrowGGGGG
Calendar yearyyyy
Calendar year, 2-digityy
Local week-numbering yearYYYY
Local week-numbering year, 2-digitYY
QuarterQ
Quarter, 2-digitQQ
Quarter, abbreviatedQQQ
Quarter, wideQQQQ
Quarter, narrowQQQQQ
Quarter, abbreviated, stand-aloneqqq
Quarter, wide, stand-aloneqqqq
Quarter, narrow, stand-aloneqqqqq
MonthM
Month, 2-digitMM
Month, abbreviatedMMM
Month, wideMMMM
Month, narrowMMMMM
Month, abbreviated, stand-aloneLLL
Month, wide, stand-aloneLLLL
Month, narrow, stand-aloneLLLLL
Local week of yearw
Local week of year, 2-digitww
Day of monthd
Day of month, 2-digitdd
Day of yearD
Day of year, 2-digitDD
Day of year, 3-digitDDD
Weekday, abbreviatedEEE
Weekday, wideEEEE
Weekday, narrowEEEEE
Weekday, shortEEEEEE
Weekday, abbreviated, stand-aloneccc
Weekday, wide, stand-alonecccc
Weekday, narrow, stand-aloneccccc
Weekday, short, stand-alonecccccc
Weekday, number (locale)e
Weekday, number (locale), 2-digitee
AM/PMa
AM/PM, wideaaaa
AM/PM, narrowaaaaa
Day period + noon/midnightb
Day period + noon/midnight, widebbbb
Day period + noon/midnight, narrowbbbbb
Flexible day periodB
Flexible day period, wideBBBB
Flexible day period, narrowBBBBB
Hour 1–12h hh
Hour 0–23H HH
Hour 1–24k kk
Hour 0–11K KK
Minutem mm
Seconds ss
Fractional secondS SS SSS
Time-zone namezzz
Offset, ±hh:mmxxx
Offset, ±hhmmxx
Offset, ±hh:mm, Z at zeroXXX
Offset, ±hhmm, Z at zeroXX

Aliases

Extra spellings that are parsed but normalize to the primary token above when rendered:

  • y / yyy → calendar year (like yyyy).
  • Y / YYY → local week-numbering year (like YYYY).
  • G / GG → abbreviated era (like GGG).
  • E / EE → abbreviated weekday (like EEE).
  • eeeeeeeee → formatting weekday name (like EEEEEEEEE).
  • L / LL → numeric month, stand-alone (like M / MM).
  • q / qq → numeric quarter, stand-alone (like Q / QQ).
  • c / cc → numeric weekday, stand-alone (like e / ee).
  • aa / aaa → AM/PM (like a).
  • bb / bbb → day period + noon/midnight (like b).
  • BB / BBB → flexible day period (like B).
  • z / zz → time-zone name (like zzz).

Caveats

  • Case is significant: y (calendar year) and Y (local week-numbering year) are different fields, as are d (day of month) and D (day of year).
  • Ordinals (Mo, Qo, wo, Do…), ISO week fields, the Unix epoch, and localized presets are not part of the bare ldml dialect. A dialect → dialect conversion literalizes them; a library that extends ldml (e.g. date-fns) provides them.
Last updated on