Open
Description
When attempting to format a NaiveDate
with time-related/unsupported specifiers, the error message is not informative.
For example:
use chrono::NaiveDate;
fn main() {
let d = NaiveDate::from_ymd_opt(2015, 9, 5).unwrap();
let _ = d.format("%Y-%m-%dT%H:%M:%S%.3f").to_string(); // uses time specifiers (i.e. %H, %M, etc...)
let _ = d.format("%Y-%m-%k").to_string(); // This is just hogwash, %k isn't a time or date specifier!
}
Both outputs:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/fmtdate`
thread 'main' panicked at /Users/matthew/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/string.rs:2688:14:
a Display implementation returned an error unexpectedly: Error
The error message could be improved indicating time specifiers or unsupported specifiers cannot be used with NaiveDate
.
Metadata
Metadata
Assignees
Labels
No labels