🔀 Merge pull request #982 from Totto16/master

- Clock Widget: fix bug, better default Handling for:  use12Hour, showSeconds
This commit is contained in:
Alicia Sykes 2022-11-26 00:44:30 +00:00 committed by GitHub
commit 475a9a1469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -40,7 +40,9 @@ export default {
return !this.options.hideSeconds;
},
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;
},
},
methods: {