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 33db991
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion juniper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ serde = { version = "1.0.122", features = ["derive"] }
serde_json = { version = "1.0.18", features = ["std"], default-features = false, optional = true }
smartstring = "1.0"
static_assertions = "1.1"
time = { version = "0.3.35", features = ["formatting", "macros", "parsing"], optional = true }
time = { version = "0.3.37", features = ["formatting", "macros", "parsing"], optional = true }
url = { version = "2.0", optional = true }
uuid = { version = "1.3", default-features = false, optional = true }

Expand Down
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 33db991

Please sign in to comment.