all client parsing tests pass except known upce

This commit is contained in:
Henry Schimke
2022-09-16 16:56:22 -05:00
parent ed646d3a63
commit f0e83abf7e
6 changed files with 125 additions and 105 deletions

View File

@@ -27,7 +27,7 @@
// import java.util.regex.Matcher;
// import java.util.regex.Pattern;
use chrono::{Date, DateTime, NaiveDateTime, TimeZone, Utc};
use chrono::{Date, DateTime, Local, NaiveDateTime, TimeZone, Utc};
use chrono_tz::Tz;
use regex::Regex;
@@ -229,6 +229,17 @@ impl CalendarParsedRXingResult {
))),
};
}
// Try a final time with an exact length
if when.len() == 15 {
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%S") {
Ok(dtm) => Ok(dtm.timestamp()),
Err(e) => Err(Exceptions::ParseException(format!(
"couldn't parse local time: {}",
e
))),
};
}
Self::parseDateTimeString(&when)
}