Support quoted tab-separated input with US date format
Parse dates in M/D/YYYY H:MM:SS AM/PM format in addition to the ISO format used in the cleaned-up test data.
This commit is contained in:
@@ -43,7 +43,9 @@ fn get_field(record: &csv::StringRecord, index: usize) -> &str {
|
||||
impl Transaction {
|
||||
pub fn from_record(record: &csv::StringRecord) -> Option<Self> {
|
||||
let date_str = get_field(record, 0);
|
||||
let date = NaiveDateTime::parse_from_str(date_str, "%Y-%m-%d %H:%M:%S").ok()?;
|
||||
let date = NaiveDateTime::parse_from_str(date_str, "%m/%d/%Y %I:%M:%S %p")
|
||||
.or_else(|_| NaiveDateTime::parse_from_str(date_str, "%Y-%m-%d %H:%M:%S"))
|
||||
.ok()?;
|
||||
|
||||
Some(Transaction {
|
||||
date,
|
||||
|
||||
Reference in New Issue
Block a user