Add 12 hour option to clock widget

This commit is contained in:
rtm516 2022-10-08 21:42:15 +01:00
parent 29814a9fec
commit b48a341cdd
No known key found for this signature in database
GPG Key ID: 331715B8B007C67A
2 changed files with 5 additions and 0 deletions

View File

@ -110,6 +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`
#### Example

View File

@ -39,6 +39,9 @@ export default {
showSeconds() {
return !this.options.hideSeconds;
},
use12Hour() {
return !this.options.use12Hour;
},
},
methods: {
update() {
@ -52,6 +55,7 @@ export default {
hour: 'numeric',
minute: 'numeric',
...(this.showSeconds && { second: 'numeric' }),
...(this.use12Hour && { hourCycle: 'h12' }),
}).format();
},
/* Get and format the date */