use chrono::{DateTime, SecondsFormat, Utc};
pub fn dt_to_string(dt: &DateTime<Utc>) -> String {
dt.to_rfc3339_opts(SecondsFormat::AutoSi, true)
}
#[cfg(test)]
mod tests {
use chrono::TimeZone;
use pretty_assertions::assert_eq;
use super::*;
#[test]
fn test_dt_to_string() {
let dt = Utc
.with_ymd_and_hms(2022, 7, 8, 18, 16, 3)
.single()
.unwrap();
assert_eq!(dt_to_string(&dt), "2022-07-08T18:16:03Z");
}
}