Utilização

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

Declaração do tipo

ts
export type Calendar = CalendarInfo;

Membros 4

NomeTipoObrigatórioDescrição
calendarstringSimThe CLDR identifier, as gregory, buddhist or japanese.
timeZonestringSimIANA, as Europe/Lisbon.
uses24hourClockbooleanSim—
firstWeekdaynumberSim1 is Sunday, 7 is Saturday.
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.