What does ParseError (NotEnough) mean for rust?

I use rust-chrono, and I'm trying to parse a date like this:

extern crate chrono;

use chrono::*;

fn main() {

    let date_str = "2013-02-14 15:41:07";
    let date = DateTime::parse_from_str(&date_str, "%Y-%m-%d %H:%M:%S");
    match date {
        Ok(v) => println!("{:?}", v),
        Err(e) => println!("{:?}", e)
    }

}

And this is the result:

ParseError(NotEnough)

What does it mean? Not enough of what? Should I use some other library?

+4
source share
2 answers

You have to use

UTC.datetime_from_str(&date_str, "%Y-%m-%d %H:%M:%S");

how

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)
    }

}
+3
source

Types that implement Errorhave more convenient error messages via Error::descriptionor Display:

Err(e) => println!("{}", e)

Fingerprints:

not enough for unique dates and times

Presumably, this is because you did not specify a time zone, so the time is ambiguous.

+6
source

All Articles