1pub mod account;
2pub mod app_auth;
3pub mod deploy_config;
4pub mod deploy_config_update;
5pub mod error_codes;
6pub mod forgot;
7pub mod frontend_app;
8pub mod login;
9pub mod mail;
10pub mod oauth;
11pub mod project;
12pub mod repository;
13pub mod reset_password_response;
14pub mod runner;
15pub mod signup;
16pub mod tenant;
17
18pub mod ar_date_format {
19 use chrono::{DateTime, Utc};
20 use serde::{self, Deserialize, Deserializer, Serializer};
21
22 const FORMAT: &str = "%Y-%m-%dT%H:%M:%S%.f%#z";
23
24 pub fn serialize<S>(date: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error>
32 where
33 S: Serializer,
34 {
35 let s = format!("{}", date.naive_utc());
36 serializer.serialize_str(&s)
37 }
38
39 pub fn deserialize<'de, D>(deserializer: D) -> Result<DateTime<Utc>, D::Error>
47 where
48 D: Deserializer<'de>,
49 {
50 let s = String::deserialize(deserializer)?;
51 DateTime::parse_from_str(&s, FORMAT)
52 .map(|dt| dt.with_timezone(&Utc))
53 .map_err(serde::de::Error::custom)
54 }
55
56 #[cfg(test)]
57 mod tests {
58 use super::*;
59 use chrono::TimeZone;
60 use serde_json::json;
61 #[test]
62 fn test_ar_date_format() {
63 let date = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0);
64 let json = json!("2020-01-01T00:00:00Z");
65 assert_eq!(serde_json::to_value(date.unwrap()).unwrap(), json);
66 }
67 }
68}