fix: timezone caching (#371)

This commit is contained in:
stefan-gorules
2025-07-04 10:05:35 +02:00
committed by GitHub
parent 95c8cc97df
commit 09f59e9bb2
+9 -4
View File
@@ -185,12 +185,17 @@ mod helper {
use rust_decimal::prelude::ToPrimitive;
use std::ops::{Add, Deref};
use std::str::FromStr;
use std::sync::OnceLock;
fn tz() -> Tz {
iana_time_zone::get_timezone()
.ok()
.and_then(|tz| Tz::from_str(&tz).ok())
.unwrap_or_else(|| Tz::UTC)
static CACHED_TZ: OnceLock<Tz> = OnceLock::new();
*CACHED_TZ.get_or_init(|| {
iana_time_zone::get_timezone()
.ok()
.and_then(|tz| Tz::from_str(&tz).ok())
.unwrap_or_else(|| Tz::UTC)
})
}
pub fn now() -> DateTime<Tz> {