Skip to content

Commit

Permalink
🔀 Merge pull request Lissy93#982 from Totto16/master
Browse files Browse the repository at this point in the history
- Clock Widget: fix bug, better default Handling for:  use12Hour, showSeconds
  • Loading branch information
Lissy93 authored Nov 26, 2022
2 parents 77aee8b + 74370ac commit 475a9a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 475a9a1

Please sign in to comment.