-
Notifications
You must be signed in to change notification settings - Fork 592
Closed
Labels
Description
If the timestamp of a DateTime
is near the end of the range of NaiveDateTime
and the offset pushes the timestamp beyond that range, the Debug
implementation can panic.
#[test]
fn test_datetime_debug_min_max() {
let offset = FixedOffset::west_opt(3600).unwrap();
let local_min = offset.from_utc_datetime(&NaiveDateTime::MIN);
assert_eq!(format!("{:?}", local_min), "-262144-12-31T23:00:00-01:00");
/* not yet sure this is the proper string */
let offset = FixedOffset::east_opt(3600).unwrap();
let local_max = offset.from_utc_datetime(&NaiveDateTime::MAX);
assert_eq!(format!("{:?}", local_max), "+262144-01-01T00:59:59.999999999");
/* not yet sure this is the proper string */
}
This is extra fun when the panic happens while panicking, where you may want to write the debug value of the DateTime
. (i.e. (signal: 6, SIGABRT: process abort signal)
).
jtmoon79