Skip to content

Commit

Permalink
Update Date32 and Date64
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Mar 5, 2023
1 parent 2652a5d commit e767860
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arrow-cast/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,19 @@ const ERR_NANOSECONDS_NOT_SUPPORTED: &str = "The dates that can be represented a

impl Parser for Date32Type {
fn parse(string: &str) -> Option<i32> {
let date = string.parse::<chrono::NaiveDate>().ok()?;
let date = parse_date(string.as_bytes().try_into().ok()?).ok()?;
Some(date.num_days_from_ce() - EPOCH_DAYS_FROM_CE)
}

fn parse_formatted(string: &str, format: &str) -> Option<i32> {
let date = chrono::NaiveDate::parse_from_str(string, format).ok()?;
let date = NaiveDate::parse_from_str(string, format).ok()?;
Some(date.num_days_from_ce() - EPOCH_DAYS_FROM_CE)
}
}

impl Parser for Date64Type {
fn parse(string: &str) -> Option<i64> {
let date_time = string.parse::<NaiveDateTime>().ok()?;
let date_time = string_to_datetime(&Utc, string).ok()?;
Some(date_time.timestamp_millis())
}

Expand Down

0 comments on commit e767860

Please sign in to comment.