Verwendung

Format a clock using the device's calendar preferences.

tsx
// Format a clock using the device's calendar preferences.
import { localization, type Calendar } from 'kuito';

export function clockLabel(date: Date): string {
  const calendar: Calendar | undefined = localization.calendars.value[0];
  return new Intl.DateTimeFormat(localization.locales.value[0]?.languageTag, {
    hour: 'numeric',
    minute: '2-digit',
    timeZone: calendar?.timeZone ?? undefined,
    hour12: calendar?.uses24hourClock == null ? undefined : !calendar.uses24hourClock,
  }).format(date);
}

Typdeklaration

ts
export type Calendar = CalendarInfo;

Mitglieder 4

NameTypErforderlichBeschreibung
calendarstringJaThe CLDR identifier, as gregory, buddhist or japanese.
timeZonestringJaIANA, as Europe/Lisbon.
uses24hourClockbooleanJa—
firstWeekdaynumberJa1 is Sunday, 7 is Saturday.
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.