From fa0ec302caa1ec496d44f097ac8d31b1d9a02139 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 5 Mar 2023 21:59:42 +0000 Subject: [PATCH] Add extra tests for nanosecond and millisecond parsing --- lib/src/sql/datetime.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/src/sql/datetime.rs b/lib/src/sql/datetime.rs index a4bd471e..cd6871b9 100644 --- a/lib/src/sql/datetime.rs +++ b/lib/src/sql/datetime.rs @@ -307,6 +307,24 @@ mod tests { assert_eq!("'2012-04-24T02:55:43.511Z'", format!("{}", out)); } + #[test] + fn date_time_timezone_utc_nanoseconds() { + let sql = "2012-04-23T18:25:43.5110000Z"; + let res = datetime_raw(sql); + assert!(res.is_ok()); + let out = res.unwrap().1; + assert_eq!("'2012-04-23T18:25:43.511Z'", format!("{}", out)); + } + + #[test] + fn date_time_timezone_utc_sub_nanoseconds() { + let sql = "2012-04-23T18:25:43.0000511Z"; + let res = datetime_raw(sql); + assert!(res.is_ok()); + let out = res.unwrap().1; + assert_eq!("'2012-04-23T18:25:43.000051100Z'", format!("{}", out)); + } + #[test] fn date_time_illegal_date() { // Hey! There's not a 31st of November!