What does ParseError(NotEnough) from rust-chrono mean?
Types that implement Error
have more user-friendly error messages via Error::description
or Display
:
Err(e) => println!("{}", e)
This prints:
input is not enough for unique date and time
Presumably this is because you haven't provided a timezone, thus the time is ambiguous.
You should use
UTC.datetime_from_str(&date_str, "%Y-%m-%d %H:%M:%S");
Like:
extern crate chrono;
use chrono::*;
fn main() {
let date_str = "2013-02-14 15:41:07";
let date = UTC.datetime_from_str(&date_str, "%Y-%m-%d %H:%M:%S");
match date {
Ok(v) => println!("{:?}", v),
Err(e) => println!("{:?}", e)
}
}