diff --git a/src/common/i18n.mjs b/src/common/i18n.mjs index 89aab02..7dab580 100644 --- a/src/common/i18n.mjs +++ b/src/common/i18n.mjs @@ -22,6 +22,12 @@ export const locales = [ export const defaultLocale = locales.find(l => l.code === 'en-US'); +const datetimeFormats = { + dateTimeShort: { month: 'numeric', day: 'numeric', hour: 'numeric', minute: '2-digit' }, + dateTimeShortWeekday: { month: 'numeric', weekday: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }, + time: { hour: 'numeric', minute: '2-digit' }, +}; + let i18n = null; export function initializeI18n() { @@ -30,6 +36,7 @@ export function initializeI18n() { locale: currentLocale().code, fallbackLocale: 'en-US', messages: { ...languages }, + datetimeFormats: locales.reduce((result, locale) => ({ ...result, [locale.code]: datetimeFormats }), {}), }); // Listen for local storage changes diff --git a/src/common/time.js b/src/common/time.js index 7e3b158..807cc3b 100644 --- a/src/common/time.js +++ b/src/common/time.js @@ -1,14 +1,6 @@ import { useI18n } from 'vue-i18n'; import { useTimeStore } from '../stores/time'; -export function formatDateTime(value) { - return (new Date(value)).toLocaleString(undefined, { month: 'numeric', day: 'numeric', hour: 'numeric', minute: '2-digit' }); -} - -export function formatTime(value) { - return (new Date(value)).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' }); -} - function getDurationParts(value) { let negative = (value < 0) ? '-' : ''; value = Math.abs(value); diff --git a/src/components/ScheduleBox.vue b/src/components/ScheduleBox.vue index 11be975..8d8ce19 100644 --- a/src/components/ScheduleBox.vue +++ b/src/components/ScheduleBox.vue @@ -27,9 +27,9 @@