From bd90167f4ea90cb97984b9f3b5e6f65b375d0c4a Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Fri, 30 Jun 2023 11:10:19 +0100 Subject: [PATCH] feat(clock): format option for popup header --- docs/modules/Clock.md | 9 ++++++--- src/modules/clock.rs | 34 +++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/modules/Clock.md b/docs/modules/Clock.md index a513987..13932c7 100644 --- a/docs/modules/Clock.md +++ b/docs/modules/Clock.md @@ -8,9 +8,12 @@ Clicking on the widget opens a popup with the time and a calendar. > Type: `clock` -| Name | Type | Default | Description | -|----------|----------|------------------|------------------------------------------------------------------------------------------------------------------------------------------| -| `format` | `string` | `%d/%m/%Y %H:%M` | Date/time format string. Detail on available tokens can be found here: | +| Name | Type | Default | Description | +|----------------|----------|------------------|---------------------------------------------------------| +| `format` | `string` | `%d/%m/%Y %H:%M` | Date/time format string. | +| `format_popup` | `string` | `%H:%M:%S` | Date/time format string to display in the popup header. | + +> Detail on available tokens can be found here:
JSON diff --git a/src/modules/clock.rs b/src/modules/clock.rs index 4102f92..e974466 100644 --- a/src/modules/clock.rs +++ b/src/modules/clock.rs @@ -23,6 +23,9 @@ pub struct ClockModule { #[serde(default = "default_format")] format: String, + #[serde(default = "default_popup_format")] + format_popup: String, + #[serde(flatten)] pub common: Option, } @@ -31,6 +34,10 @@ fn default_format() -> String { String::from("%d/%m/%Y %H:%M") } +fn default_popup_format() -> String { + String::from("%H:%M:%S") +} + impl Module