diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2024-02-06 17:47:00 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-06 17:47:00 +0000 |
| commit | 199365310248eecedf8fbad579fc0cdc2e47bbe7 (patch) | |
| tree | 0380b351a55291df39dcb8c7af324e4bc5786365 /atuin-client/src/settings.rs | |
| parent | Add timezone configuration option & CLI overrides (#1517) (diff) | |
| download | atuin-199365310248eecedf8fbad579fc0cdc2e47bbe7.zip | |
fix(tests): add Settings::utc() for utc settings (#1677)
Means we don't try and load timezones in tests, as this fails due to
multiple threads.
Also allow specifying '0' or 'utc' as a timezone
Diffstat (limited to 'atuin-client/src/settings.rs')
| -rw-r--r-- | atuin-client/src/settings.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index 7abacd0d..f4c47c64 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -155,6 +155,11 @@ impl FromStr for Timezone { return Ok(Self(offset)); } + if matches!(s.to_lowercase().as_str(), "0" | "utc") { + let offset = UtcOffset::UTC; + return Ok(Self(offset)); + } + // offset from UTC if let Ok(offset) = UtcOffset::parse(s, OFFSET_FMT) { return Ok(Self(offset)); @@ -355,6 +360,17 @@ pub struct Settings { } impl Settings { + pub fn utc() -> Self { + Self::builder() + .expect("Could not build default") + .set_override("timezone", "0") + .expect("failed to override timezone with UTC") + .build() + .expect("Could not build config") + .try_deserialize() + .expect("Could not deserialize config") + } + fn save_to_data_dir(filename: &str, value: &str) -> Result<()> { let data_dir = atuin_common::utils::data_dir(); let data_dir = data_dir.as_path(); |
