From fcda20013b8836e171a91c8c47c584449ffd7746 Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Wed, 29 Jul 2020 14:18:44 -0500 Subject: Update Date and Time Settings to include UTC/offset label Label updates allow the user to easily understand the expectation for entering time by using specific label text for "24 hour time" and removing parenthesis from the helper text as parenthesis are not needed to in the input field. UTC/offset is displayed based on user preference. Signed-off-by: Dixsie Wolmers Change-Id: I41f98d9d16f0a4a81af39ce9b25768a1c0b89f08 --- src/components/Mixins/LocalTimezoneLabelMixin.js | 14 +++++++++++ src/locales/en-US.json | 7 ++++-- .../DateTimeSettings/DateTimeSettings.vue | 27 ++++++++++++++++++---- src/views/ProfileSettings/ProfileSettings.vue | 14 ++++++----- 4 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 src/components/Mixins/LocalTimezoneLabelMixin.js (limited to 'src') diff --git a/src/components/Mixins/LocalTimezoneLabelMixin.js b/src/components/Mixins/LocalTimezoneLabelMixin.js new file mode 100644 index 00000000..0f96a45f --- /dev/null +++ b/src/components/Mixins/LocalTimezoneLabelMixin.js @@ -0,0 +1,14 @@ +import { format } from 'date-fns-tz'; + +const LocalTimezoneLabelMixin = { + methods: { + localOffset() { + const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + const shortTz = this.$options.filters.shortTimeZone(new Date()); + const pattern = `'${shortTz}' O`; + return format(new Date(), pattern, { timezone }).replace('GMT', 'UTC'); + } + } +}; + +export default LocalTimezoneLabelMixin; diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 63c75367..fa00c86e 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -134,12 +134,15 @@ "alert": { "message": "To change how date and time are displayed (either UTC or browser offset) throughout the application, visit ", "link": "Profile Settings" - }, + }, "configureSettings": "Configure settings", "form": { "date": "Date", "manual": "Manual", - "time": "Time", + "time": { + "label": "24-hour time", + "timezone": "@:pageDateTimeSettings.form.time.label (%{timezone})" + }, "ntpServers": { "server1": "Server 1", "server2": "Server 2", diff --git a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue index f1b64751..3d9dc3b6 100644 --- a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue +++ b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue @@ -24,7 +24,7 @@
-
{{ $t('pageDateTimeSettings.form.time') }}
+
{{ $t('pageDateTimeSettings.form.time.label') }}
{{ bmcTime | formatTime }}
--
@@ -52,7 +52,7 @@ :label="$t('pageDateTimeSettings.form.date')" label-for="input-manual-date" > - (YYYY-MM-DD) + YYYY-MM-DD - (HH:MM) + HH:MM