ldml
The Unicode LDML (UTS #35) date-field grammar. Imported from rosetta-date/dialects:
import { ldml } from 'rosetta-date/dialects'- Spec: Unicode UTS #35 Date Field Symbol Table
- Family:
delimited— ASCII letters are token characters - Literals: quotes
'...'; a literal apostrophe is''— see Literals & Adjacency
Tokens
Each token and the canonical field it maps to. For how these compare across dialects, see Token Mapping.
| Meaning | Token |
|---|---|
| Era, abbreviated | GGG |
| Era, wide | GGGG |
| Era, narrow | GGGGG |
| Calendar year | yyyy |
| Calendar year, 2-digit | yy |
| Local week-numbering year | YYYY |
| Local week-numbering year, 2-digit | YY |
| Quarter | Q |
| Quarter, 2-digit | QQ |
| Quarter, abbreviated | QQQ |
| Quarter, wide | QQQQ |
| Quarter, narrow | QQQQQ |
| Quarter, abbreviated, stand-alone | qqq |
| Quarter, wide, stand-alone | qqqq |
| Quarter, narrow, stand-alone | qqqqq |
| Month | M |
| Month, 2-digit | MM |
| Month, abbreviated | MMM |
| Month, wide | MMMM |
| Month, narrow | MMMMM |
| Month, abbreviated, stand-alone | LLL |
| Month, wide, stand-alone | LLLL |
| Month, narrow, stand-alone | LLLLL |
| Local week of year | w |
| Local week of year, 2-digit | ww |
| Day of month | d |
| Day of month, 2-digit | dd |
| Day of year | D |
| Day of year, 2-digit | DD |
| Day of year, 3-digit | DDD |
| Weekday, abbreviated | EEE |
| Weekday, wide | EEEE |
| Weekday, narrow | EEEEE |
| Weekday, short | EEEEEE |
| Weekday, abbreviated, stand-alone | ccc |
| Weekday, wide, stand-alone | cccc |
| Weekday, narrow, stand-alone | ccccc |
| Weekday, short, stand-alone | cccccc |
| Weekday, number (locale) | e |
| Weekday, number (locale), 2-digit | ee |
| AM/PM | a |
| AM/PM, wide | aaaa |
| AM/PM, narrow | aaaaa |
| Day period + noon/midnight | b |
| Day period + noon/midnight, wide | bbbb |
| Day period + noon/midnight, narrow | bbbbb |
| Flexible day period | B |
| Flexible day period, wide | BBBB |
| Flexible day period, narrow | BBBBB |
| Hour 1–12 | h hh |
| Hour 0–23 | H HH |
| Hour 1–24 | k kk |
| Hour 0–11 | K KK |
| Minute | m mm |
| Second | s ss |
| Fractional second | S SS SSS |
| Time-zone name | zzz |
Offset, ±hh:mm | xxx |
Offset, ±hhmm | xx |
Offset, ±hh:mm, Z at zero | XXX |
Offset, ±hhmm, Z at zero | XX |
Aliases
Extra spellings that are parsed but normalize to the primary token above when rendered:
y/yyy→ calendar year (likeyyyy).Y/YYY→ local week-numbering year (likeYYYY).G/GG→ abbreviated era (likeGGG).E/EE→ abbreviated weekday (likeEEE).eee…eeeeee→ formatting weekday name (likeEEE…EEEEEE).L/LL→ numeric month, stand-alone (likeM/MM).q/qq→ numeric quarter, stand-alone (likeQ/QQ).c/cc→ numeric weekday, stand-alone (likee/ee).aa/aaa→ AM/PM (likea).bb/bbb→ day period + noon/midnight (likeb).BB/BBB→ flexible day period (likeB).z/zz→ time-zone name (likezzz).
Caveats
- Case is significant:
y(calendar year) andY(local week-numbering year) are different fields, as ared(day of month) andD(day of year). - Ordinals (
Mo,Qo,wo,Do…), ISO week fields, the Unix epoch, and localized presets are not part of the bareldmldialect. Adialect → dialectconversion literalizes them; a library that extendsldml(e.g. date-fns) provides them.
Last updated on