Usage

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);
}

Type declaration

ts
export type Calendar = CalendarInfo;

Members 4

NameTypeRequiredDescription
calendarstringYesThe CLDR identifier, as gregory, buddhist or japanese.
timeZonestringYesIANA, as Europe/Lisbon.
uses24hourClockbooleanYes—
firstWeekdaynumberYes1 is Sunday, 7 is Saturday.
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.