From b6dcb02df8d6e4c38a800a4769e6e9eed2b94d70 Mon Sep 17 00:00:00 2001 From: Oliver Cooper Date: Thu, 3 Jun 2021 10:12:32 +1200 Subject: [PATCH] Aligned NaiveDateTime formatting with DateTime Fixes #526 Chrono uses `%Y-%m-%dT%H:%M:%S%.f%:z` for it's RCC3339 formatting implementation. See https://github.com/chronotope/chrono/blob/3467172c31188006147585f6ed3727629d642fed/src/format/mod.rs#L680 --- src/types/external/naive_time.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/types/external/naive_time.rs b/src/types/external/naive_time.rs index b597690f..406e9480 100644 --- a/src/types/external/naive_time.rs +++ b/src/types/external/naive_time.rs @@ -20,13 +20,13 @@ impl ScalarType for NaiveDate { impl ScalarType for NaiveTime { fn parse(value: Value) -> InputValueResult { match value { - Value::String(s) => Ok(NaiveTime::parse_from_str(&s, "%H:%M:%S")?), + Value::String(s) => Ok(NaiveTime::parse_from_str(&s, "%H:%M:%S%.f")?), _ => Err(InputValueError::expected_type(value)), } } fn to_value(&self) -> Value { - Value::String(self.format("%H:%M:%S").to_string()) + Value::String(self.format("%H:%M:%S%.f").to_string()) } } @@ -34,12 +34,12 @@ impl ScalarType for NaiveTime { impl ScalarType for NaiveDateTime { fn parse(value: Value) -> InputValueResult { match value { - Value::String(s) => Ok(NaiveDateTime::parse_from_str(&s, "%Y-%m-%d %H:%M:%S")?), + Value::String(s) => Ok(NaiveDateTime::parse_from_str(&s, "%Y-%m-%dT%H:%M:%S%.f")?), _ => Err(InputValueError::expected_type(value)), } } fn to_value(&self) -> Value { - Value::String(self.format("%Y-%m-%d %H:%M:%S").to_string()) + Value::String(self.format("%Y-%m-%dT%H:%M:%S%.f").to_string()) } }