ArcTz's offset prints the time zone's name in Debug, not the offset, so DateTime serializes into an incorrect format.
use chrono::{DateTime, NaiveDate, TimeZone};
use serde::Serialize;
use tzfile::ArcTz;
#[derive(Debug, Serialize)]
pub struct Foo {
pub date: DateTime<ArcTz>,
}
fn main() {
let tz = ArcTz::named("Europe/Budapest").unwrap();
let dt = tz.from_utc_datetime(&NaiveDate::from_ymd(2021, 3, 11).and_hms(17, 49, 32));
println!("{:?}", dt.offset());
let foo = Foo { date: dt };
let j = serde_json::to_string(&foo).unwrap();
println!("{}", j);
}
Chrono's Serialize implementation uses Debug formatting for Serialize, and assumes that it will produce valid RFC 3339: https://docs.rs/chrono/0.4.19/src/chrono/datetime.rs.html#2066
https://docs.rs/chrono/0.4.19/src/chrono/datetime.rs.html#720
ArcTz's offset prints the time zone's name in Debug, not the offset, so DateTime serializes into an incorrect format.
For example:
This prints
{"date":"2021-03-11T18:49:32CET"}, which isn't valid RFC3339.