Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

Add 12 hour option to clock widget

rtm516b48a341cddc9
diff --git a/docs/widgets.md b/docs/widgets.md
index 8ec4d860..be7151e6 100644
--- a/docs/widgets.md
+++ b/docs/widgets.md
@@ -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
diff --git a/src/components/Widgets/Clock.vue b/src/components/Widgets/Clock.vue
index 948a5f68..d72eb1ab 100644
--- a/src/components/Widgets/Clock.vue
+++ b/src/components/Widgets/Clock.vue
@@ -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 */