1use std::fmt::Display;
2
3use chrono::{DateTime, TimeZone};
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
8pub struct IsoString(pub String);
9
10impl IsoString {
11 pub fn now() -> Self {
13 Self(chrono::Utc::now().to_rfc3339())
14 }
15
16 pub fn from_datetime<T: TimeZone>(datetime: &DateTime<T>) -> Self
18 where
19 T::Offset: Display,
20 {
21 Self(datetime.to_rfc3339())
22 }
23
24 pub fn as_str(&self) -> &str {
26 &self.0
27 }
28}