From 605172a0bc84c169b9380652566b5f6307fa4d2f Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Mon, 6 Sep 2021 10:22:01 +0200 Subject: [PATCH] Align internal and fecha date/time formatting (#9380) --- src/common/datetime/format_date_time.ts | 4 ++-- src/common/datetime/format_time.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/datetime/format_date_time.ts b/src/common/datetime/format_date_time.ts index 0b91a40b81..eddc74aec4 100644 --- a/src/common/datetime/format_date_time.ts +++ b/src/common/datetime/format_date_time.ts @@ -16,7 +16,7 @@ const formatDateTimeMem = memoizeOne( year: "numeric", month: "long", day: "numeric", - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", hour12: useAmPm(locale), }) @@ -34,7 +34,7 @@ const formatDateTimeWithSecondsMem = memoizeOne( year: "numeric", month: "long", day: "numeric", - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", second: "2-digit", hour12: useAmPm(locale), diff --git a/src/common/datetime/format_time.ts b/src/common/datetime/format_time.ts index a20e1feef5..c1511fb8eb 100644 --- a/src/common/datetime/format_time.ts +++ b/src/common/datetime/format_time.ts @@ -13,7 +13,7 @@ export const formatTime = toLocaleTimeStringSupportsOptions const formatTimeMem = memoizeOne( (locale: FrontendLocaleData) => new Intl.DateTimeFormat(locale.language, { - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", hour12: useAmPm(locale), }) @@ -28,7 +28,7 @@ export const formatTimeWithSeconds = toLocaleTimeStringSupportsOptions const formatTimeWithSecondsMem = memoizeOne( (locale: FrontendLocaleData) => new Intl.DateTimeFormat(locale.language, { - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", second: "2-digit", hour12: useAmPm(locale), @@ -45,7 +45,7 @@ const formatTimeWeekdayMem = memoizeOne( (locale: FrontendLocaleData) => new Intl.DateTimeFormat(locale.language, { weekday: "long", - hour: "numeric", + hour: useAmPm(locale) ? "numeric" : "2-digit", minute: "2-digit", hour12: useAmPm(locale), })