Bug:the From Trait Wront Impl for kilickhouse::DateTime and Chrono::DateTime
csh0101 opened this issue · comments
Random commented
hello,my bro.i'm a beginner on Rust,so maybe something i say sounds childrens,on your eyes..
Problem
https://stackoverflow.com/questions/61179070/rust-chrono-parse-date-string-parseerrornotenough-and-parseerrortooshort
I want to conver a standard datatime "2022-04-22 00:00:00" convert to the klickhouse::DateTime.
it should be okay,but failed. During finding the bug step by step, I write a test for this.
#[test]
fn test_consistency_with_convert_for_str() {
let test_date = "2022-04-22 00:00:00";
let dt = chrono::NaiveDateTime::parse_from_str(test_date, "%Y-%m-%d %H:%M:%S").unwrap();
let chrono_date =
chrono::DateTime::<Tz>::from_utc(dt, chrono_tz::UTC.offset_from_utc_datetime(&dt));
let date = DateTime(UTC, dt.timestamp() as u32);
let new_chrono_date: chrono::DateTime<Tz> = date.into();
assert_eq!(new_chrono_date, chrono_date);
}
also,there have two test before in the file src/values/date.rs...i confrim the old impl for From cant not pass this test_case.
@Protryon