@@ -56,7 +56,8 @@ const DATE_FORMAT: &[FormatItem<'_>] = format_description!("[year]-[month]-[day]
56
56
See also [`time::Date`][2] for details.\
57
57
\n \n \
58
58
[1]: https://graphql-scalars.dev/docs/scalars/date\n \
59
- [2]: https://docs.rs/time/*/time/struct.Date.html"
59
+ [2]: https://docs.rs/time/*/time/struct.Date.html",
60
+ specified_by_url = "https://graphql-scalars.dev/docs/scalars/date"
60
61
) ]
61
62
impl < S : ScalarValue > GraphQLScalar for Date {
62
63
fn resolve ( & self ) -> Value {
@@ -98,7 +99,8 @@ const LOCAL_TIME_FORMAT_NO_MILLIS: &[FormatItem<'_>] =
98
99
/// [1]: https://graphql-scalars.dev/docs/scalars/local-time
99
100
const LOCAL_TIME_FORMAT_NO_SECS : & [ FormatItem < ' _ > ] = format_description ! ( "[hour]:[minute]" ) ;
100
101
101
- #[ graphql_scalar( description = "Clock time within a given date (without time zone) in \
102
+ #[ graphql_scalar(
103
+ description = "Clock time within a given date (without time zone) in \
102
104
`HH:mm[:ss[.SSS]]` format.\
103
105
\n \n \
104
106
All minutes are assumed to have exactly 60 seconds; no \
@@ -110,7 +112,9 @@ const LOCAL_TIME_FORMAT_NO_SECS: &[FormatItem<'_>] = format_description!("[hour]
110
112
See also [`time::Time`][2] for details.\
111
113
\n \n \
112
114
[1]: https://graphql-scalars.dev/docs/scalars/local-time\n \
113
- [2]: https://docs.rs/time/*/time/struct.Time.html") ]
115
+ [2]: https://docs.rs/time/*/time/struct.Time.html",
116
+ specified_by_url = "https://graphql-scalars.dev/docs/scalars/local-time"
117
+ ) ]
114
118
impl < S : ScalarValue > GraphQLScalar for LocalTime {
115
119
fn resolve ( & self ) -> Value {
116
120
Value :: scalar (
@@ -198,12 +202,14 @@ impl<S: ScalarValue> GraphQLScalar for LocalDateTime {
198
202
\n \n \
199
203
[0]: https://datatracker.ietf.org/doc/html/rfc3339#section-5.6\n \
200
204
[1]: https://graphql-scalars.dev/docs/scalars/date-time\n \
201
- [2]: https://docs.rs/time/*/time/struct.OffsetDateTime.html"
205
+ [2]: https://docs.rs/time/*/time/struct.OffsetDateTime.html",
206
+ specified_by_url = "https://graphql-scalars.dev/docs/scalars/date-time"
202
207
) ]
203
208
impl < S : ScalarValue > GraphQLScalar for DateTime {
204
209
fn resolve ( & self ) -> Value {
205
210
Value :: scalar (
206
- self . format ( & Rfc3339 )
211
+ self . to_offset ( UtcOffset :: UTC )
212
+ . format ( & Rfc3339 )
207
213
. unwrap_or_else ( |e| panic ! ( "Failed to format `DateTime`: {}" , e) ) ,
208
214
)
209
215
}
@@ -214,6 +220,7 @@ impl<S: ScalarValue> GraphQLScalar for DateTime {
214
220
. and_then ( |s| {
215
221
Self :: parse ( s, & Rfc3339 ) . map_err ( |e| format ! ( "Invalid `DateTime`: {}" , e) )
216
222
} )
223
+ . map ( |dt| dt. to_offset ( UtcOffset :: UTC ) )
217
224
}
218
225
219
226
fn from_str < ' a > ( value : ScalarToken < ' a > ) -> ParseScalarResult < ' a , S > {
@@ -241,7 +248,8 @@ const UTC_OFFSET_FORMAT: &[FormatItem<'_>] =
241
248
\n \n \
242
249
[0]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n \
243
250
[1]: https://graphql-scalars.dev/docs/scalars/utc-offset\n \
244
- [2]: https://docs.rs/time/*/time/struct.UtcOffset.html"
251
+ [2]: https://docs.rs/time/*/time/struct.UtcOffset.html",
252
+ specified_by_url = "https://graphql-scalars.dev/docs/scalars/utc-offset"
245
253
) ]
246
254
impl < S : ScalarValue > GraphQLScalar for UtcOffset {
247
255
fn resolve ( & self ) -> Value {
@@ -508,7 +516,7 @@ mod date_time_test {
508
516
) ,
509
517
(
510
518
"2014-11-28T21:00:09.05+09:00" ,
511
- datetime ! ( 2014 -11 -28 21 : 00 : 09.05 +9 ) ,
519
+ datetime ! ( 2014 -11 -28 12 : 00 : 09.05 +0 ) ,
512
520
) ,
513
521
] {
514
522
let input: InputValue = graphql_input_value ! ( ( raw) ) ;
@@ -567,7 +575,7 @@ mod date_time_test {
567
575
) ,
568
576
(
569
577
datetime ! ( 1564 -01 -30 14 : 00 +9 ) ,
570
- graphql_input_value ! ( "1564-01-30T14 :00:00+09:00 " ) ,
578
+ graphql_input_value ! ( "1564-01-30T05 :00:00Z " ) ,
571
579
) ,
572
580
] {
573
581
let actual: InputValue = val. to_input_value ( ) ;
@@ -711,7 +719,7 @@ mod integration_test {
711
719
"date" : "2015-03-14" ,
712
720
"localTime" : "16:07:08" ,
713
721
"localDateTime" : "2016-07-08 09:10:11" ,
714
- "dateTime" : "1996-12-19T16 :39:57-08:00 " ,
722
+ "dateTime" : "1996-12-20T00 :39:57Z " ,
715
723
"utcOffset" : "+11:30" ,
716
724
} ) ,
717
725
vec![ ] ,
0 commit comments