From 4bb3114e3c8cfcb4a60a8b93fa13662696e46ea7 Mon Sep 17 00:00:00 2001 From: tyranron Date: Tue, 3 Dec 2024 18:43:42 +0100 Subject: [PATCH] Allow spaces as separators for `DateTime` scalars as per RFC 3339 (time-rs/time#700) --- juniper/src/integrations/bson.rs | 24 +++++++++++++++++++++++- juniper/src/integrations/time.rs | 6 +++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/juniper/src/integrations/bson.rs b/juniper/src/integrations/bson.rs index 06957935d..e64a3cf45 100644 --- a/juniper/src/integrations/bson.rs +++ b/juniper/src/integrations/bson.rs @@ -137,6 +137,17 @@ mod date_time_test { .build() .unwrap(), ), + ( + "2014-11-28 21:00:09z", + DateTime::builder() + .year(2014) + .month(11) + .day(28) + .hour(21) + .second(9) + .build() + .unwrap(), + ), ( "2014-11-28T21:00:09+00:00", DateTime::builder() @@ -160,6 +171,18 @@ mod date_time_test { .build() .unwrap(), ), + ( + "2014-11-28 21:00:09.05+09:00", + DateTime::builder() + .year(2014) + .month(11) + .day(28) + .hour(12) + .second(9) + .millisecond(50) + .build() + .unwrap(), + ), ] { let input: InputValue = graphql_input_value!((raw)); let parsed = DateTime::from_input_value(&input); @@ -181,7 +204,6 @@ mod date_time_test { graphql_input_value!("56:34:22"), graphql_input_value!("56:34:22.000"), graphql_input_value!("1996-12-1914:23:43"), - graphql_input_value!("1996-12-19 14:23:43Z"), graphql_input_value!("1996-12-19T14:23:43"), graphql_input_value!("1996-12-19T14:23:43ZZ"), graphql_input_value!("1996-12-19T14:23:43.543"), diff --git a/juniper/src/integrations/time.rs b/juniper/src/integrations/time.rs index 63a3e245f..52b018d0c 100644 --- a/juniper/src/integrations/time.rs +++ b/juniper/src/integrations/time.rs @@ -490,6 +490,7 @@ mod date_time_test { datetime!(2014-11-28 21:00:09 +9), ), ("2014-11-28T21:00:09Z", datetime!(2014-11-28 21:00:09 +0)), + ("2014-11-28 21:00:09z", datetime!(2014-11-28 21:00:09 +0)), ( "2014-11-28T21:00:09+00:00", datetime!(2014-11-28 21:00:09 +0), @@ -498,6 +499,10 @@ mod date_time_test { "2014-11-28T21:00:09.05+09:00", datetime!(2014-11-28 12:00:09.05 +0), ), + ( + "2014-11-28 21:00:09.05+09:00", + datetime!(2014-11-28 12:00:09.05 +0), + ), ] { let input: InputValue = graphql_input_value!((raw)); let parsed = DateTime::from_input_value(&input); @@ -519,7 +524,6 @@ mod date_time_test { graphql_input_value!("56:34:22"), graphql_input_value!("56:34:22.000"), graphql_input_value!("1996-12-1914:23:43"), - graphql_input_value!("1996-12-19 14:23:43Z"), graphql_input_value!("1996-12-19T14:23:43"), graphql_input_value!("1996-12-19T14:23:43ZZ"), graphql_input_value!("1996-12-19T14:23:43.543"),