From c286e0244c289f7139a06787f5e91bab635f258b Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 3 Jan 2024 02:05:49 +0100 Subject: [PATCH] Add time_zone config option --- CHANGELOG.md | 1 + cove-config/src/lib.rs | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d7166..6a22b86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Procedure when bumping the version number: ### Added - Support for multiple euph server domains +- `time_zone` config option - `--domain` option to `cove export` command - `--domain` option to `cove clear-cookies` command - Domain field to "connect to new room" popup diff --git a/cove-config/src/lib.rs b/cove-config/src/lib.rs index 5aa6522..5d88867 100644 --- a/cove-config/src/lib.rs +++ b/cove-config/src/lib.rs @@ -77,18 +77,40 @@ pub struct Config { /// Initial sort order of rooms list. /// - /// `alphabet` sorts rooms in alphabetic order. + /// `"alphabet"` sorts rooms in alphabetic order. /// - /// `importance` sorts rooms by the following criteria (in descending order - /// of priority): + /// `"importance"` sorts rooms by the following criteria (in descending + /// order of priority): /// /// 1. connected rooms before unconnected rooms /// 2. rooms with unread messages before rooms without /// 3. alphabetic order #[serde(default)] - #[document(default = "`alphabet`")] + #[document(default = "`\"alphabet\"`")] pub rooms_sort_order: RoomsSortOrder, + /// Time zone that chat timestamps should be displayed in. + /// + /// This option is interpreted as a POSIX TZ string. It is described here in + /// further detail: + /// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html + /// + /// On a normal system, the string `"localtime"` as well as any value from + /// the "TZ identifier" column of the following wikipedia article should be + /// valid TZ strings: + /// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + /// + /// If the option is not specified, cove uses the contents of the `TZ` + /// environment variable instead. If the `TZ` environment variable does not + /// exist, cove uses the system's local time zone. + /// + /// **Warning:** On Windows, cove can't get the local time zone and uses UTC + /// instead. However, you can still specify a path to a tz data file or a + /// custom time zone string. + #[serde(default)] + #[document(default = "$TZ or local time zone")] + pub time_zone: Option, + #[serde(default)] #[document(no_default)] pub euph: Euph, @@ -115,4 +137,8 @@ impl Config { } EuphRoom::default() } + + pub fn time_zone_ref(&self) -> Option<&str> { + self.time_zone.as_ref().map(|s| s as &str) + } }