use chrono::{DateTime, FixedOffset, Utc}; pub const DEFAULT_TIMEZONE_OFFSET: i32 = -6 * 3600; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct LocalTimestampRange { pub start: DateTime, pub end: DateTime, } #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct UtcTimestampRange { pub start: DateTime, pub end: DateTime, } impl From for UtcTimestampRange { fn from(item: LocalTimestampRange) -> Self { Self { start: item.start.to_utc(), end: item.end.to_utc(), } } } /// Super naive implementation. Just a quick and dirty to get a string pub fn tz_offset_to_string(tz_offset_seconds: i32) -> String { if tz_offset_seconds == 3600 * -6 { return "Central".to_string(); } else if tz_offset_seconds == 3600 * -5 { return "Eastern".to_string(); } else if tz_offset_seconds == 3600 * -7 { return "Pacific".to_string(); } else if tz_offset_seconds < 0 { return format!("UTC{}", tz_offset_seconds).to_string(); } format!("UTC+{}", tz_offset_seconds).to_string() }