# Values, time zones and globalization

> Plain, frozen, Temporal-compatible date and time values with ISO serialization, the accepted inputs, IANA time zones with DST, Intl locales, digits, calendar systems, patterns and localeText.

Canonical: https://salmonui.dev/docs/calendars/dates

Every calendar component (Calendar, RangeCalendar, DateField, TimeField and
the pickers that follow) uses the same value types and globalization rules.
The types and helpers are exported from each calendar subpath
(`@salmonui/calendars/calendar`, `/date-picker`, `/time-picker`) under the same
names.

## Value types

| Type | Fields | `String(value)` / `JSON.stringify` |
| --- | --- | --- |
| `PlainDate` | `year`, `month` (1-12), `day` | `2026-11-23` |
| `PlainTime` | `hour`, `minute`, `second`, `millisecond` | `14:30:00` |
| `PlainDateTime` | both | `2026-11-23T14:30:00` |
| `DateRange<T>` | `start`, `end` | an object of two ISO strings |

Outputs are frozen objects whose prototype carries `toString()` and
`toJSON()`, so they serialize as ISO strings. `month` is always 1-12 and
`year` is the ISO (proleptic Gregorian) year, whatever calendar the
component displays. Temporal is not required: the field names are
Temporal's, so a `Temporal.PlainDate` works as an input as it is, and
`Temporal.PlainDate.from(value)` accepts an output as a property bag. Across
a React Server Components boundary pass ISO strings or plain field objects
(RSC does not serialize prototypes).

## Inputs

`DateInput`, `TimeInput` and `DateTimeInput` accept:

- an object with the fields (`{ year: 2026, month: 11, day: 23 }`,
  `Temporal.*` objects included);
- an ISO 8601 string: a date (`'2026-11-23'`), a time (`'14:30'`,
  `'14:30:05'`) or a date-time (`'2026-11-23T14:30'`); with `Z` or an offset
  (`'2026-11-23T13:30:00Z'`) it is an instant;
- a `Date`, which is an instant: its wall-clock fields are read in the
  component's `timeZone`.

Locale text is never accepted as a value (only typed or pasted by the user).
An invalid input (`'2026-02-30'`, an invalid `Date`) is treated as empty and
logs a development warning; it never throws during render.

```ts
import { getRangeDays, toDate, toPlainDate, toPlainDateTime, toPlainTime } from '@salmonui/calendars/calendar';

toPlainDate('2026-11-23');                                  // PlainDate 2026-11-23
toPlainDate(new Date('2026-11-23T23:30:00Z'), 'Asia/Tokyo'); // 2026-11-24
toPlainTime('14:30');                                        // 14:30:00
toPlainDateTime({ year: 2026, month: 11, day: 23, hour: 9, minute: 0 });
getRangeDays({ start: toPlainDate('2026-11-03')!, end: toPlainDate('2026-11-09')! }); // 7
toDate(toPlainDateTime('2026-11-23T09:00')!, 'Europe/Berlin'); // the instant 08:00Z
```

## Time zones

`timeZone` (an IANA name such as `'America/New_York'`) matters only for
instants (a `Date`, an offset string, `details.epochMilliseconds`) and for
"today". Plain values never depend on a zone. Offsets come from
`Intl.DateTimeFormat#formatToParts` with one cached formatter per zone, and
DST is handled like Temporal's `disambiguation: 'compatible'`: a wall time in
a spring-forward gap moves forward by the gap (02:30 on 2026-03-08 in New
York is 03:30 EDT), an ambiguous one in a fall-back overlap takes the
earlier instant. Without `timeZone` the client uses the host zone; the
server never uses its own, so zone-dependent text is deferred to hydration
with sized placeholders (`data-salmon-deferred`). Zones are IANA names, not
fixed minute offsets, so they follow DST.

### Live demo: Formats, locales and time zones

Live demo: https://salmonui.dev/demos/calendars/calendar-picker-formats

Pattern and Intl display formats, extra input formats for typing and paste, German strings through localeText, a Date value in Asia/Tokyo, seconds with a 12-hour clock, a New York DST gap and a calendar week rule.

`Demo.tsx`:

```tsx
'use client';

import { useState } from 'react';
import { Calendar, type WeekRule } from '@salmonui/calendars/calendar';
import { DatePicker, type DatePickerValueChangeDetails, type PlainDate, type PlainDateTime } from '@salmonui/calendars/date-picker';
import { DateRangePicker, type DateRange } from '@salmonui/calendars/date-range-picker';
import { TimePicker } from '@salmonui/calendars/time-picker';
import { Select } from '@salmonui/dropdowns/select';

// A fixed instant: 2026-11-23 14:00 UTC (a `Date` value, read in the picker's zone).
const MEETING = new Date(Date.UTC(2026, 10, 23, 14, 0));

type Change = { field: string; text: string; json: string; iso: string };

/** Display formats, typed and pasted input formats, locales and localeText, Date and ISO values, seconds, 12-hour time and a DST day. */
export default function CalendarPickerFormatsDemo() {
  const [last, setLast] = useState<Change | null>(null);
  const [rule, setRule] = useState<WeekRule>('firstFourDayWeek');
  const report = (field: string) => (value: PlainDate | PlainDateTime | null, details: DatePickerValueChangeDetails) =>
    setLast({ field, text: String(value), json: JSON.stringify(value), iso: details.iso });
  const reportRange = (value: DateRange | null) => setLast({ field: 'Trip', text: value ? `${String(value.start)} / ${String(value.end)}` : 'null', json: JSON.stringify(value), iso: value ? `${String(value.start)}/${String(value.end)}` : '' });
  return (
    <div style={{ display: 'grid', gap: 20 }}>
      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'flex-start' }}>
        <DatePicker
          label="Invoice date (dd/MM/yyyy)"
          description="Also accepts 23.11.2026 and 20261123 typed over the field or pasted."
          format="dd/MM/yyyy"
          inputFormats={['d.M.yyyy', 'yyyyMMdd']}
          defaultValue="2026-11-23"
          locale="en-GB"
          onValueChange={report('Invoice date')}
        />
        <DatePicker
          label="Lieferdatum (de-DE)"
          locale="de-DE"
          format={{ day: '2-digit', month: 'long', year: 'numeric' }}
          defaultValue="2026-12-07"
          clearable
          localeText={{ chooseDate: 'Datum wählen', clear: 'Löschen', close: 'Schließen' }}
          onValueChange={report('Lieferdatum')}
        />
        <DatePicker
          label="Call in Tokyo (a Date value)"
          description="value is a Date instant; the field shows it in Asia/Tokyo."
          granularity="minute"
          defaultValue={MEETING}
          timeZone="Asia/Tokyo"
          locale="en-US"
          onValueChange={report('Call in Tokyo')}
        />
        <DatePicker
          label="Deploy at (seconds, 12-hour)"
          granularity="second"
          hourCycle="h12"
          defaultValue="2026-11-23T21:15:30"
          inputFormats={['yyyy-MM-dd HH:mm:ss']}
          strict
          clearable
          min="2026-11-01T00:00:00"
          locale="en-US"
          onValueChange={report('Deploy at')}
        />
        <DatePicker
          label="Clocks change (America/New_York)"
          description="8 March 2026: 02:00 to 02:59 does not exist. Set the hour to 2 and watch the offset."
          granularity="minute"
          defaultValue="2026-03-08T01:30"
          timeZone="America/New_York"
          hourCycle="h23"
          locale="en-US"
          onValueChange={report('Clocks change')}
        />
        <TimePicker
          label="Opening time (h23)"
          format={{ hour: '2-digit', minute: '2-digit' }}
          hourCycle="h23"
          defaultValue="08:30"
          locale="en-GB"
          onValueChange={(value, details) => setLast({ field: 'Opening time', text: String(value), json: JSON.stringify(value), iso: details.iso })}
        />
        <DateRangePicker label="Trip (dd MMM yyyy)" format="dd MMM yyyy" locale="en-GB" defaultValue={{ start: '2026-12-21', end: '2026-12-27' }} onValueChange={reportRange} />
      </div>
      <div style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'flex-start' }}>
        <div>
          <label className="demo-toolbar">
            Week rule
            <Select aria-label="Week rule" data={[{ value: 'firstDay', label: 'firstDay (US)' }, { value: 'firstFourDayWeek', label: 'firstFourDayWeek (ISO 8601)' }, { value: 'firstFullWeek', label: 'firstFullWeek' }]} value={rule} onValueChange={(value) => value != null && setRule(value as WeekRule)} />
          </label>
          <Calendar aria-label="January 2027 with week numbers" defaultFocusedValue="2027-01-01" showWeekNumbers weekRule={rule} firstDayOfWeek={1} locale="en-GB" />
        </div>
        <div className="demo-log" style={{ flex: '1 1 320px' }} aria-live="polite">
          {last ? (
            <>
              <div>field: {last.field}</div>
              <div>String(value): {last.text}</div>
              <div>JSON.stringify(value): {last.json}</div>
              <div>details.iso: {last.iso || "''"}</div>
            </>
          ) : (
            'Change a field to see its value'
          )}
        </div>
      </div>
    </div>
  );
}
```

## Locale

`locale` (BCP 47) is a prop on every component and defaults to `'en-US'`;
the host locale (`navigator.language`) is never read during render, so
server and client markup match. Month and weekday names, digits, era, day
period and segment order all come from `Intl`; no CLDR JSON is loaded,
because the browser and Node already ship the
data through `Intl`.

- **Numbering systems** follow the locale or its `-u-nu-` extension:
  `ar-EG` shows Arabic-Indic digits in day cells, headings and segments, and
  typing or pasting accepts both Latin and locale digits.
- **Calendar systems**: `calendar` or `-u-ca-` relabels the month heading
  and the full-date accessible names; Japanese (`令和8年11月`), Buddhist
  (`พ.ศ. 2569`) and ROC years appear in the heading while the value stays
  ISO. The year segment of `DateField` and the pickers keeps the ISO year
  (`2026`), as the Data Grid date editor's text input does.
- **Patterns**: `format` and `inputFormats` accept the Data Grid pattern
  grammar: `yyyy`, `yy`, `M`, `MM`, `MMM`, `MMMM`, `d`, `dd`, `H`, `HH`,
  `h`, `hh`, `m`, `mm`, `s`, `ss`, `a` and quoted literals (`'dd.MM.yyyy'`,
  `'d MMM yyyy'`, `'hh:mm a'`), as well as CLDR skeletons (`'yMMMd'`) and
  `Intl.DateTimeFormatOptions`.

## localeText

User-visible strings live in a `localeText` catalog per component, in the
Data Grid message format: a `{param}` template or plural forms chosen by
`Intl.PluralRules` (`{ one, other }`). Pass only the keys you translate;
the rest stay English.

```tsx
<Calendar
  locale="de-DE"
  localeText={{ previousMonth: 'Vorheriger Monat', nextMonth: 'Nächster Monat', today: 'Heute', weekNumber: 'KW', weekNumberLabel: 'Kalenderwoche {week}' }}
/>
<DateField locale="de-DE" localeText={{ dayPlaceholder: 'TT', monthPlaceholder: 'MM', yearPlaceholder: 'JJJJ', empty: 'Leer' }} />
```

## API reference

The API reference for
[`@salmonui/calendars/calendar`](https://salmonui.dev/docs/reference/calendars/calendar),
[`@salmonui/calendars/date-picker`](https://salmonui.dev/docs/reference/calendars/date-picker),
[`@salmonui/calendars/date-range-picker`](https://salmonui.dev/docs/reference/calendars/date-range-picker)
and [`@salmonui/calendars/time-picker`](https://salmonui.dev/docs/reference/calendars/time-picker) lists
every prop, method and type.
