Skip to content

Token Specification & Cross-Ecosystem Matrix ​

This document provides a comprehensive cross-reference matrix comparing date formatting and parsing tokens across Native Tempo Core, Unicode LDML / UTS #35 (Luxon, date-fns), Moment.js / Day.js, and POSIX strftime (C, Python, SQL).


1. Comprehensive Token Cross-Reference Matrix ​

CategoryDescriptionUnicode LDML / LuxonMoment.js / Day.jsPOSIX strftimeNative Tempo {token}
Year4-digit calendar year (2026)yyyy or yYYYY%Y{yyyy}
2-digit calendar year (26)yyYY%y{yy}
4-digit ISO week-numbering yearYYYYGGGG or gggg%G{yw}
2-digit ISO week-numbering yearYYGG or gg%g{yy} (with week context)
MonthZero-padded month (01-12)MM or LLMM%m{mm}
Unpadded month (1-12)M or LM%-m{mm:raw}
Month with ordinal suffix (10th)N/AMoN/A{mm:ord}
Short month name (Oct)MMM or LLLMMM%b or %h{mmm}
Full month name (October)MMMM or LLLLMMMM%B{mon}
Day of MonthZero-padded day (01-31)ddDD%d{dd}
Unpadded day (1-31)dD%e or %-d{dd:raw}
Day with ordinal suffix (24th)N/ADoN/A{dd:ord}
Day of YearDay of year (001-366)DDDDDDD%j{doy}
Unpadded day of year (1-366)DDDD%-j{doy:raw}
Week of YearZero-padded ISO week (01-53)wwWW%V{wy}
Unpadded ISO week (1-53)wW%-V{wy:raw}
WeekdayFull weekday name (Saturday)EEEE or ccccdddd%A{wkd}
Short weekday name (Sat)EEE or cccddd%a{www}
2-character weekday name (Sa)N/AddN/A{www} (or slice)
ISO Day of week (1 = Mon ... 7 = Sun)c or eN/A%u{dow}
POSIX Day of week (0 = Sun ... 6 = Sat)N/Ad%w{dow} (ISO adjusted)
Hour (24h)Zero-padded 24-hour (00-23)HHHH%H{hh}
Unpadded 24-hour (0-23)HH%k or %-H{hh:raw}
Zero-padded 24-hour (01-24)kkkkN/A{hh} (normalized)
Hour (12h)Zero-padded 12-hour (01-12)hhhh%I{h12}
Unpadded 12-hour (1-12)hh%l or %-I{h12:raw}
MeridiemUppercase AM/PM (AM / PM)aa or aA%p{mer:upper}
Lowercase am/pm (am / pm)aa%P{mer}
MinuteZero-padded minute (00-59)mmmm%M{mi}
Unpadded minute (0-59)mm%-M{mi:raw}
SecondZero-padded second (00-59)ssss%S{ss}
Unpadded second (0-59)ss%-S{ss:raw}
FractionalMilliseconds (000-999)SSSSSSN/A{ms}
Hundredths (00-99)SSSSN/A{ff:2}
Tenths (0-9)SSN/A{ff:1}
Microseconds (000000-999999)N/AN/A%f{ff:6}
TimestampUnix timestamp (seconds)N/AX%s{ts}
Unix timestamp (milliseconds)N/AxN/A{ts:ms}
TimezoneShort abbreviation (PST, UTC)zzz or zzz or z%Z{tz:short}
Full localized name (Pacific Standard Time)zzzzN/AN/A{tz:long}
Compact offset (-0800, +0530)ZZ or ZZZ%z{tz:offsetcompact}
Extended ISO offset (-08:00, +05:30)ZZZZZZ%:z{tz:offset}
Localized GMT offset (GMT-08:00)ZZZZN/AN/A{tz:longoffset}
QuarterQuarter number (1-4)Q or qQN/A{#quarter} (with Term)
Quarter with ordinal (3rd)N/AQoN/A{#quarter:ord}
Full quarter name (3rd quarter)QQQQN/AN/A{#quarter}

2. Literal Text Escaping Rules ​

When embedding arbitrary plain text inside format strings, each dialect implements distinct syntax:

A. Unicode LDML & Luxon ​

  • Wrap arbitrary characters in single quotes: 'Date: ' yyyy-MM-dd.
  • To emit a literal single quote, use two consecutive single quotes: ''yyyy'' → '2026'.
typescript
// LDML Escaping Example
const str1 = t.format("'Report generated on' yyyy-MM-dd 'at' HH:mm", { dialect: 'ldml' });
// Output: "Report generated on 2026-10-24 at 15:30"

B. Moment.js & Day.js ​

  • Wrap arbitrary characters in square brackets: [Report generated on] YYYY-MM-DD.
  • Single characters outside brackets that do not match known tokens are emitted as literals.
typescript
// Moment Escaping Example
const str2 = t.format('[Invoice #] YYYY-MM-DD [due by] HH:mm', { dialect: 'moment' });
// Output: "Invoice # 2026-10-24 due by 15:30"

C. POSIX strftime ​

  • Any character not prefixed by % is treated as literal text.
  • To emit a literal percent sign, use %%: %% %Y-%m-%d → % 2026-10-24.
typescript
// strftime Escaping Example
const str3 = t.format('%% System status at %Y-%m-%d %H:%M:%S %%', { dialect: 'strftime' });
// Output: "% System status at 2026-10-24 15:30:45 %"

D. Native Tempo Core ​

  • In Native Tempo syntax, tokens are enclosed in curly braces {token}. Everything outside braces is literal text by default.
  • To emit a literal { or }, use {{ or }}:
typescript
// Native Tempo Escaping Example
const str4 = t.format('Total balance: ${0} as of {yyyy}-{mm}-{dd}', { dialect: null });
// Output: "Total balance: $0 as of 2026-10-24"

3. Hour Parsing & Normalization Details ​

When parsing 24-hour clocks, differing standards support both 00-23 (HH, H) and 01-24 (kk, k):

  • In Unicode LDML, kk indicates hours from 01 to 24. Hour 24:00 represents midnight at the end of the day, which standard Temporal engines normalize to 00:00.
  • The Dialects parser safely normalizes 24:00 to hour 0, while strictly rejecting out-of-range hours like 25:00 or 00:00 for kk tokens:
typescript
const validMidnight = Tempo.fromFormat('2026-10-24 24:00', 'yyyy-MM-dd kk:mm');
console.log(validMidnight.hh); // 0 (normalized)

const invalidHour = Tempo.fromFormat('2026-10-24 25:00', 'yyyy-MM-dd kk:mm', { error: 'catch' });
console.log(invalidHour.isValid); // false

Released under the MIT License.