Skip to content

Composables

Date helpers

Conversions between the ISO YYYY-MM-DD strings the date components model and the CalendarDate values Reka's calendars require, plus formatting for display.

model → 2026-08-15

formatIsoDate → Aug 15, 2026

de-DE, full → Samstag, 15. August 2026

isoToday() → 2026-08-24

Why a string and not a Date

A Date carries a time zone: new Date('2026-08-15') parses as UTC midnight, so a reader west of Greenwich formatting it locally sees the 14th. Stored as '2026-08-15' the date stays the day that was picked, wherever it is read.

The helpers

FunctionSignature
toCalendarDate(iso) => CalendarDate | undefinedISO string → the value Reka's calendars take
toIsoDate(date) => string | nullBack the other way
isoToday() => stringToday in the local zone, as YYYY-MM-DD
formatIsoDate(iso, locale?, options?) => stringFor display; '' for absent or malformed input

formatIsoDate defaults to { dateStyle: 'medium' } and takes any Intl.DateTimeFormatOptions. It returns an empty string rather than throwing on bad input, so a caller can fall back to a placeholder without a try.

CalendarDate and the DateValue type are re-exported, so you can work with @internationalized/date without adding it to your own dependencies.

Formatting elsewhere

The model is a plain string, so format it with Intl, dayjs or anything else you already use.