pub fn to_arrow_date32(value: TPCHDate) -> i32Expand description
Convert a TPCH date to an Arrow Date32.
- Arrow
Date32are days since the epoch (1970-01-01) TPCHDates are days since MIN_GENERATE_DATE (1992-01-01)
use chrono::NaiveDate;
use spatialbench::dates::TPCHDate;
let arrow_epoch = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap();
let tpch_epoch = NaiveDate::from_ymd_opt(1992, 1, 1).unwrap();
// the difference between the two epochs is 8035 days
let day_offset = (tpch_epoch - arrow_epoch).num_days();
let day_offset: i32 = day_offset.try_into().unwrap();
assert_eq!(day_offset, TPCHDate::UNIX_EPOCH_OFFSET);