calamine
calamine copied to clipboard
"dates" feature is not accurate enough, maybe
The dates feature is not accurate enough.
Actual:
- Make the xlsx file with the value
2021-10-15 19:00:00of DateTime typed. - Read the value using
as_date()withfeatures=["dates"] - The result is "2021-10-15 18:59:59.999999761".
Expected:
- The result is "2021-10-15 19:00:00".
Guessing:
- Maybe, this constant is not accurate enough:
- https://github.com/tafia/calamine/blob/master/src/datatype.rs#L127
FYI:
I was tested in the below code, and it was taken the correct result.
pub fn to_naive_from_excel_datetime(v: f64) -> NaiveDateTime
{
let excel_epoch = NaiveDate::from_ymd(1899, 12, 30).and_hms(0, 0, 0);
let h = v * 24f64;
let m = h * 60f64;
let s = m * 60f64;
let ms = s * 1e+3f64;
let excel_duration = Duration::milliseconds(ms as i64);
excel_epoch + excel_duration
}
But, I know this implementation has an overheads and you don't like the explainly implements maybe. Therefore, I didn't PR and just write the issue only.