1
0
Fork 0

handle datetime (de)serialization

This commit is contained in:
Cyborus 2024-01-18 18:10:05 -05:00
parent bfb31fc296
commit 194a1b5e36
No known key found for this signature in database
2 changed files with 82 additions and 0 deletions

View file

@ -728,6 +728,12 @@ fn create_struct_for_definition(
if field_ty == "Option<url::Url>" {
fields.push_str("#[serde(deserialize_with = \"crate::none_if_blank_url\")]\n");
}
if field_ty == "time::OffsetDateTime" {
fields.push_str("#[serde(with = \"time::serde::rfc3339\")]\n");
}
if field_ty == "Option<time::OffsetDateTime>" {
fields.push_str("#[serde(with = \"time::serde::rfc3339::option\")]\n");
}
if &field_name != prop_name {
fields.push_str("#[serde(rename = \"");
fields.push_str(prop_name);