Token Mapping
This is the grammar layer — what translates between dialects, independent of any tool. Each row is one canonical meaning and the token each dialect uses to spell it. Behaviour specific to a concrete library lives in Library Notes.
The tables below list the tokens that round-trip between dialects.
Era & year
| Meaning | moment | ldml |
|---|---|---|
| Era, abbreviated | N | GGG |
| Era, wide | NNNN | GGGG |
| Era, narrow | NNNNN | GGGGG |
| Calendar year | YYYY | yyyy |
| Calendar year, 2-digit | YY | yy |
| Local week-numbering year | gggg | YYYY |
| Local week-numbering year, 2-digit | gg | YY |
Month & quarter
| Meaning | moment | ldml |
|---|---|---|
| Quarter | Q | Q |
| Quarter, ordinal | Qo | Qo |
| Month | M | M |
| Month, 2-digit | MM | MM |
| Month, ordinal | Mo | Mo |
| Month, abbreviated | MMM | MMM |
| Month, wide | MMMM | MMMM |
Week & day
| Meaning | moment | ldml |
|---|---|---|
| Week of year | w | w |
| Week of year, 2-digit | ww | ww |
| Week of year, ordinal | wo | wo |
| Day of month | D | d |
| Day of month, 2-digit | DD | dd |
| Day of month, ordinal | Do | do |
| Day of year | DDD | D |
| Day of year, 3-digit | DDDD | DDD |
| Day of year, ordinal | DDDo | Do |
Weekday
| Meaning | moment | ldml |
|---|---|---|
| Weekday, abbreviated | ddd | EEE |
| Weekday, wide | dddd | EEEE |
| Weekday, short | dd | EEEEEE |
| Weekday, number | d | e |
Time
| Meaning | moment | ldml |
|---|---|---|
| AM/PM | A | a |
| Hour 1–12 | h | h |
| Hour 1–12, 2-digit | hh | hh |
| Hour 0–23 | H | H |
| Hour 0–23, 2-digit | HH | HH |
| Hour 1–24 | k | k |
| Hour 1–24, 2-digit | kk | kk |
| Minute | m | m |
| Minute, 2-digit | mm | mm |
| Second | s | s |
| Second, 2-digit | ss | ss |
| Fractional second (1–3 digits) | S SS SSS | S SS SSS |
Time zone
| Meaning | moment | ldml |
|---|---|---|
| Time-zone name | z | zzz |
Offset, ±hh:mm | Z | xxx |
Offset, ±hhmm | ZZ | xx |
Aliases
A few extra spellings are parsed but normalize to the primary token above when rendered:
momentY→ calendar year (likeYYYY).ldmly/yyy→ calendar year;EE→ abbreviated weekday;aa/aaa→ AM/PM;z/zz→ time-zone name.
Tokens with no moment counterpart
Some ldml tokens have no moment counterpart, so converting them to moment produces an escaped
literal (e.g. MMMMM → [MMMMM]) rather than a wrong guess.
ldml | Meaning |
|---|---|
MMMMM | Narrow month |
EEEEE | Narrow weekday |
aaaa aaaaa | Wide / narrow day period |
K KK | Hour 0–11 |
DD | Day of year, 2-digit |
A few mappings are intentionally lossy. moment d (weekday number, 0–6) and ldml e
(locale-dependent) map to each other but use different numbering; the AM/PM marker loses its
moment casing (A/a both become a); and moment’s narrow era (NNNNN) renders the
abbreviation (AD), not a true one-character form.
date-fns adds extension tokens that also have no moment counterpart (PPPP, Pp, …). Localized
preset behaviour is covered in Library Notes → Localized presets.