fix(time): Update applet timezone on change

Closes: #582

The chrono crate caches the local timezone but doesn't update it. This
makes sense because it'd be inefficient to constantly evaluate the local
timezone.

Instead of using the local timezone, this patch changes the applet to
use a fixed offset internally which is updated if the external timezone
changes.
This commit is contained in:
Josh Megnauth 2024-08-17 00:40:10 -04:00 committed by Michael Murphy
parent f43705d31f
commit 323e8a55b2
3 changed files with 139 additions and 5 deletions

52
Cargo.lock generated
View file

@ -706,6 +706,28 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "chrono-tz"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb"
dependencies = [
"chrono",
"chrono-tz-build",
"phf",
]
[[package]]
name = "chrono-tz-build"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1"
dependencies = [
"parse-zoneinfo",
"phf",
"phf_codegen",
]
[[package]]
name = "clipboard-win"
version = "5.4.0"
@ -1141,16 +1163,19 @@ name = "cosmic-applet-time"
version = "0.1.0"
dependencies = [
"chrono",
"chrono-tz",
"i18n-embed 0.14.1",
"i18n-embed-fl 0.8.0",
"icu",
"libcosmic",
"once_cell",
"rust-embed 8.5.0",
"timedate-zbus",
"tokio",
"tracing",
"tracing-log",
"tracing-subscriber",
"zbus 4.3.1",
]
[[package]]
@ -4436,6 +4461,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "parse-zoneinfo"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24"
dependencies = [
"regex",
]
[[package]]
name = "paste"
version = "1.0.15"
@ -4458,6 +4492,16 @@ dependencies = [
"phf_shared",
]
[[package]]
name = "phf_codegen"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
dependencies = [
"phf_generator",
"phf_shared",
]
[[package]]
name = "phf_generator"
version = "0.11.2"
@ -5705,6 +5749,14 @@ dependencies = [
"time-core",
]
[[package]]
name = "timedate-zbus"
version = "0.1.0"
source = "git+https://github.com/pop-os/dbus-settings-bindings#cd21ddcb1b5cbfc80ab84b34d3c8b1ff3d81179a"
dependencies = [
"zbus 4.3.1",
]
[[package]]
name = "tiny-keccak"
version = "2.0.2"