Skip to content

Commit

Permalink
Allow spaces as separators for DateTime scalars as per RFC 3339 (ti…
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Dec 3, 2024
1 parent 5f39b37 commit 4bb3114
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 23 additions & 1 deletion juniper/src/integrations/bson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand All @@ -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"),
Expand Down
6 changes: 5 additions & 1 deletion juniper/src/integrations/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand All @@ -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"),
Expand Down

0 comments on commit 4bb3114

Please sign in to comment.