在chrono的代码中,我们可以找到以下测试:
assert_eq!(format!("{:?}", NaiveDate::from_ymd(2012, 3, 4)), "2012-03-04");
assert_eq!(format!("{:?}", NaiveDate::from_ymd(0, 3, 4)), "0000-03-04");
assert_eq!(format!("{:?}", NaiveDate::from_ymd(-307, 3, 4)), "-0307-03-04");
assert_eq!(format!("{:?}", NaiveDate::from_ymd(12345, 3, 4)), "+12345-03-04");为什么它是+12345-03-04而不仅仅是12345-03-04没有领先的+
在使用DateTime::to_rfc3339格式速记时,这种行为类似。
在说明文档或RFC 3339中,我找不到任何关于这一领先加的任何提及。根据某种规格,这是正确的吗?+的含义是什么?什么时候包括?
发布于 2022-07-01 11:32:12
https://docs.rs/chrono/0.4.19/src/chrono/naive/date.rs.html#1639-1650
// ISO 8601 requires the explicit sign for out-of-range years
write!(f, "{:+05}-{:02}-{:02}", year, mdf.month(), mdf.day())https://stackoverflow.com/questions/72828561
复制相似问题