From c197e08af059c214dfc0ac148269bc6b8466954b Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Wed, 26 Aug 2026 15:38:55 -0400 Subject: [PATCH] Default the CLI to the system time zone It shipped with America/Denver hardcoded, taken from what dominates the historical data on the server. That data is old; the reader has moved. A zone belongs to whoever is looking at the calendar, and baking one in is the same mistake as v1's offset-instead-of-zone in miniature -- it looks right until the reader is somewhere else. Falls back to UTC rather than to a populated guess: an obviously neutral wrong answer gets noticed, a plausible one does not. --- Cargo.lock | 1 + Cargo.toml | 1 + crates/runway-cli/Cargo.toml | 1 + crates/runway-cli/src/main.rs | 17 ++++++++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d997942..1e04f10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2177,6 +2177,7 @@ dependencies = [ "chrono", "chrono-tz", "clap", + "iana-time-zone", "runway-caldav", "runway-core", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 65e6c2d..467ab42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,6 +60,7 @@ leptos_router = "0.8" # CLI clap = { version = "4", features = ["derive", "env"] } +iana-time-zone = "0.1" # Dev pretty_assertions = "1" diff --git a/crates/runway-cli/Cargo.toml b/crates/runway-cli/Cargo.toml index 485f913..bbe9b8f 100644 --- a/crates/runway-cli/Cargo.toml +++ b/crates/runway-cli/Cargo.toml @@ -11,6 +11,7 @@ runway-caldav = { workspace = true } chrono = { workspace = true } chrono-tz = { workspace = true } clap = { workspace = true } +iana-time-zone = { workspace = true } tokio = { workspace = true } tracing = { workspace = true } tracing-subscriber = { workspace = true } diff --git a/crates/runway-cli/src/main.rs b/crates/runway-cli/src/main.rs index 9033b3c..bf5ab95 100644 --- a/crates/runway-cli/src/main.rs +++ b/crates/runway-cli/src/main.rs @@ -33,13 +33,28 @@ struct Cli { password: String, /// The zone to show times in, and to read floating times as. - #[arg(long, default_value = "America/Denver")] + /// + /// Defaults to whatever the machine is set to. Baking in a zone would be + /// the same mistake in miniature that this project exists to correct: the + /// right zone is a property of the reader, and readers move. + #[arg(long, default_value_t = local_timezone())] timezone: Tz, #[command(subcommand)] command: Command, } +/// The system's own IANA zone, falling back to UTC when it cannot be read. +/// +/// UTC rather than a guess at somewhere populated: a wrong zone that looks +/// plausible is worse than an obviously neutral one, because nobody checks it. +fn local_timezone() -> Tz { + iana_time_zone::get_timezone() + .ok() + .and_then(|name| name.parse().ok()) + .unwrap_or(Tz::UTC) +} + #[derive(Subcommand)] enum Command { /// List the calendars the server offers.