@@ -56,7 +56,8 @@ const DATE_FORMAT: &[FormatItem<'_>] = format_description!("[year]-[month]-[day]
5656 See also [`time::Date`][2] for details.\
5757 \n \n \
5858 [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"
6061) ]
6162impl < S : ScalarValue > GraphQLScalar for Date {
6263 fn resolve ( & self ) -> Value {
@@ -98,7 +99,8 @@ const LOCAL_TIME_FORMAT_NO_MILLIS: &[FormatItem<'_>] =
9899/// [1]: https://graphql-scalars.dev/docs/scalars/local-time
99100const LOCAL_TIME_FORMAT_NO_SECS : & [ FormatItem < ' _ > ] = format_description ! ( "[hour]:[minute]" ) ;
100101
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 \
102104 `HH:mm[:ss[.SSS]]` format.\
103105 \n \n \
104106 All minutes are assumed to have exactly 60 seconds; no \
@@ -110,7 +112,9 @@ const LOCAL_TIME_FORMAT_NO_SECS: &[FormatItem<'_>] = format_description!("[hour]
110112 See also [`time::Time`][2] for details.\
111113 \n \n \
112114 [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+ ) ]
114118impl < S : ScalarValue > GraphQLScalar for LocalTime {
115119 fn resolve ( & self ) -> Value {
116120 Value :: scalar (
@@ -198,12 +202,14 @@ impl<S: ScalarValue> GraphQLScalar for LocalDateTime {
198202 \n \n \
199203 [0]: https://datatracker.ietf.org/doc/html/rfc3339#section-5.6\n \
200204 [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"
202207) ]
203208impl < S : ScalarValue > GraphQLScalar for DateTime {
204209 fn resolve ( & self ) -> Value {
205210 Value :: scalar (
206- self . format ( & Rfc3339 )
211+ self . to_offset ( UtcOffset :: UTC )
212+ . format ( & Rfc3339 )
207213 . unwrap_or_else ( |e| panic ! ( "Failed to format `DateTime`: {}" , e) ) ,
208214 )
209215 }
@@ -214,6 +220,7 @@ impl<S: ScalarValue> GraphQLScalar for DateTime {
214220 . and_then ( |s| {
215221 Self :: parse ( s, & Rfc3339 ) . map_err ( |e| format ! ( "Invalid `DateTime`: {}" , e) )
216222 } )
223+ . map ( |dt| dt. to_offset ( UtcOffset :: UTC ) )
217224 }
218225
219226 fn from_str < ' a > ( value : ScalarToken < ' a > ) -> ParseScalarResult < ' a , S > {
@@ -241,7 +248,8 @@ const UTC_OFFSET_FORMAT: &[FormatItem<'_>] =
241248 \n \n \
242249 [0]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\n \
243250 [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"
245253) ]
246254impl < S : ScalarValue > GraphQLScalar for UtcOffset {
247255 fn resolve ( & self ) -> Value {
@@ -508,7 +516,7 @@ mod date_time_test {
508516 ) ,
509517 (
510518 "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 ) ,
512520 ) ,
513521 ] {
514522 let input: InputValue = graphql_input_value ! ( ( raw) ) ;
@@ -567,7 +575,7 @@ mod date_time_test {
567575 ) ,
568576 (
569577 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 " ) ,
571579 ) ,
572580 ] {
573581 let actual: InputValue = val. to_input_value ( ) ;
@@ -711,7 +719,7 @@ mod integration_test {
711719 "date" : "2015-03-14" ,
712720 "localTime" : "16:07:08" ,
713721 "localDateTime" : "2016-07-08 09:10:11" ,
714- "dateTime" : "1996-12-19T16 :39:57-08:00 " ,
722+ "dateTime" : "1996-12-20T00 :39:57Z " ,
715723 "utcOffset" : "+11:30" ,
716724 } ) ,
717725 vec![ ] ,
0 commit comments