From b596502fa9dead0ddd380546350a9c5072a586bb Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Fri, 16 Apr 2021 05:00:58 +0400 Subject: [PATCH] Fix 24-hour time format --- src/helpers/date.ts | 2 ++ src/lib/langPack.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/date.ts b/src/helpers/date.ts index 5a279d36..14666b4e 100644 --- a/src/helpers/date.ts +++ b/src/helpers/date.ts @@ -65,6 +65,8 @@ export function formatDateAccordingToTodayNew(time: Date) { }).element; } +MOUNT_CLASS_TO && (MOUNT_CLASS_TO.formatDateAccordingToTodayNew = formatDateAccordingToTodayNew); + export const getFullDate = (date: Date, options: Partial<{ noTime: true, noSeconds: true, diff --git a/src/lib/langPack.ts b/src/lib/langPack.ts index 54b92ac6..546c8e7e 100644 --- a/src/lib/langPack.ts +++ b/src/lib/langPack.ts @@ -352,7 +352,9 @@ namespace I18n { safeAssign(this, options); //var options = { month: 'long', day: 'numeric' }; - const dateTimeFormat = new Intl.DateTimeFormat(lastRequestedLangCode, this.options); + + // * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle#adding_an_hour_cycle_via_the_locale_string + const dateTimeFormat = new Intl.DateTimeFormat(lastRequestedLangCode + '-u-hc-h23', this.options); (this.element as any)[this.property] = capitalizeFirstLetter(dateTimeFormat.format(this.date)); }