Refactor to use new helper function

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-10-03 14:55:30 +02:00
parent 92a0713ed0
commit 3da1d9e1d9

View file

@ -75,12 +75,7 @@ fn try_to_parse_datetime(s: &str) -> Result<NaiveDateTime> {
"%Y%m%dT%H%M%SZ" "%Y%m%dT%H%M%SZ"
]; ];
for format in FORMATS { ::libimagutil::date::try_to_parse_datetime_from_string(s, FORMATS.iter())
if let Ok(parsed) = NaiveDateTime::parse_from_str(s, format) { .ok_or_else(|| format_err!("Cannot parse datetime: {}", s))
return Ok(parsed);
}
}
Err(format_err!("Cannot parse datetime: {}", s))
} }