use chrono::prelude::*; pub struct Time { pub datetime: DateTime, pub timestamp: String, pub timezone: String, } impl Time { pub fn build() -> Result> { let local: DateTime = Local::now(); // rfc3339 equiv. to stricter ISO 8601 let timestamp = local.to_rfc3339(); let tz_offset = local.format("%z").to_string(); let tz_name = iana_time_zone::get_timezone()?; let timezone = format!("{} ({})", tz_name, tz_offset); Ok(Time { datetime: local, timestamp, timezone, }) } }