Skip to content

Commit

Permalink
✨ Option to hide seconds in Clock (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed May 11, 2022
1 parent bcb1b70 commit 4287092
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>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

Expand Down
5 changes: 4 additions & 1 deletion src/components/Widgets/Clock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 */
Expand Down

0 comments on commit 4287092

Please sign in to comment.