From 49334ae3c1fb9c86f1e8c3769e9ffe9893cb6a5a Mon Sep 17 00:00:00 2001 From: Totto16 Date: Tue, 22 Nov 2022 10:41:42 +0100 Subject: [PATCH 1/4] - Clock Widget: fix bug, better default Handling for: use12Hour, showSeconds --- src/components/Widgets/Clock.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Widgets/Clock.vue b/src/components/Widgets/Clock.vue index d72eb1ab..f2d351ee 100644 --- a/src/components/Widgets/Clock.vue +++ b/src/components/Widgets/Clock.vue @@ -37,10 +37,14 @@ export default { return this.timeZone.split('/')[1].replaceAll('_', ' '); }, showSeconds() { - return !this.options.hideSeconds; + if (this.options.hideSeconds) return this.options.hideSeconds; + // this is the default + return true; }, use12Hour() { - return !this.options.use12Hour; + if (this.options.use12Hour) return this.options.use12Hour; + // this is the default, it gets computed by the DateTimeFormat implementation + return Intl.DateTimeFormat(this.timeFormat, { timeZone: this.timeZone, hour: 'numeric' }).resolvedOptions().hour12 ?? false; }, }, methods: { From becb50dc5862726c89df1b3dcbb8dcfa10997eaf Mon Sep 17 00:00:00 2001 From: Totto16 Date: Tue, 22 Nov 2022 10:46:31 +0100 Subject: [PATCH 2/4] update documentation regarding the change --- docs/widgets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/widgets.md b/docs/widgets.md index be7151e6..873fe020 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -110,7 +110,7 @@ A simple, live-updating time and date widget with time-zone support. All fields **`customCityName`** | `string` | _Optional_ | By default the city from the time-zone is shown, but setting this value will override that text **`hideDate`** | `boolean` | _Optional_ | If set to `true`, the date and city will not be shown. Defaults to `false` **`hideSeconds`** | `boolean` | _Optional_ | If set to `true`, seconds will not be shown. Defaults to `false` -**`use12Hour`** | `boolean` | _Optional_ | If set to `true`, 12 hour time will be displayed. Defaults to `false` +**`use12Hour`** | `boolean` | _Optional_ | If set to `true`, 12 hour time will be displayed. Defaults to the settings suggested by the current `format` and `timeZone` #### Example From 96684f57c8444a164cf3ac2c1139d4792c14a0f2 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Tue, 22 Nov 2022 10:58:14 +0100 Subject: [PATCH 3/4] - fixed small bug, that I forgot to port from the previous implementation --- src/components/Widgets/Clock.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Widgets/Clock.vue b/src/components/Widgets/Clock.vue index f2d351ee..26414db2 100644 --- a/src/components/Widgets/Clock.vue +++ b/src/components/Widgets/Clock.vue @@ -37,7 +37,7 @@ export default { return this.timeZone.split('/')[1].replaceAll('_', ' '); }, showSeconds() { - if (this.options.hideSeconds) return this.options.hideSeconds; + if (this.options.hideSeconds) return !this.options.hideSeconds; // this is the default return true; }, From 74370ac5577b2a859a116bdff57fa1d07a400b54 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Wed, 23 Nov 2022 22:41:39 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=8C=20Code=20review=20:=20implemen?= =?UTF-8?q?ted=20the=20requested=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Widgets/Clock.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/Widgets/Clock.vue b/src/components/Widgets/Clock.vue index 26414db2..9b238f45 100644 --- a/src/components/Widgets/Clock.vue +++ b/src/components/Widgets/Clock.vue @@ -37,12 +37,10 @@ export default { return this.timeZone.split('/')[1].replaceAll('_', ' '); }, showSeconds() { - if (this.options.hideSeconds) return !this.options.hideSeconds; - // this is the default - return true; + return !this.options.hideSeconds; }, use12Hour() { - if (this.options.use12Hour) return this.options.use12Hour; + if (typeof this.options.use12Hour === "boolean") return this.options.use12Hour; // this is the default, it gets computed by the DateTimeFormat implementation return Intl.DateTimeFormat(this.timeFormat, { timeZone: this.timeZone, hour: 'numeric' }).resolvedOptions().hour12 ?? false; },