From 4287092ea29d1260bfb485b9242e5d0b00abb3b7 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 11 May 2022 10:52:16 +0100 Subject: [PATCH] :sparkles: Option to hide seconds in Clock (#644) --- docs/widgets.md | 1 + src/components/Widgets/Clock.vue | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/widgets.md b/docs/widgets.md index 02f2d13d..8cb9d474 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -97,6 +97,7 @@ A simple, live-updating time and date widget with time-zone support. All fields **`format`** | `string` | _Optional_ | A country code for displaying the date and time in local format.
Specified as `[ISO-3166]-[ISO-639]`, for example: `en-AU`. See [here](https://www.fincher.org/Utilities/CountryLanguageList.shtml) for a full list of locales. Defaults to the browser / device's region **`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` ##### Example diff --git a/src/components/Widgets/Clock.vue b/src/components/Widgets/Clock.vue index aa5ccc51..717bad62 100644 --- a/src/components/Widgets/Clock.vue +++ b/src/components/Widgets/Clock.vue @@ -36,6 +36,9 @@ export default { if (this.options.customCityName) return this.options.customCityName; return this.timeZone.split('/')[1].replaceAll('_', ' '); }, + showSeconds() { + return !this.options.hideSeconds; + }, }, methods: { update() { @@ -48,7 +51,7 @@ export default { timeZone: this.timeZone, hour: 'numeric', minute: 'numeric', - second: 'numeric', + ...(this.showSeconds && { second: 'numeric' }), }).format(); }, /* Get and format the date */