@@ -128,13 +128,14 @@ pub mod ts_nanoseconds {
128
128
/// # use chrono::NaiveDateTime;
129
129
/// # use serde_derive::Deserialize;
130
130
/// use chrono::naive::serde::ts_nanoseconds::deserialize as from_nano_ts;
131
- /// #[derive(Deserialize)]
131
+ /// #[derive(Debug, PartialEq, Deserialize)]
132
132
/// struct S {
133
133
/// #[serde(deserialize_with = "from_nano_ts")]
134
134
/// time: NaiveDateTime
135
135
/// }
136
136
///
137
137
/// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918355733 }"#)?;
138
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1526522699, 918355733).unwrap() });
138
139
/// # Ok::<(), serde_json::Error>(())
139
140
/// ```
140
141
#[ must_use]
@@ -253,13 +254,14 @@ pub mod ts_nanoseconds_option {
253
254
/// # use chrono::naive::NaiveDateTime;
254
255
/// # use serde_derive::Deserialize;
255
256
/// use chrono::naive::serde::ts_nanoseconds_option::deserialize as from_nano_tsopt;
256
- /// #[derive(Deserialize)]
257
+ /// #[derive(Debug, PartialEq, Deserialize)]
257
258
/// struct S {
258
259
/// #[serde(deserialize_with = "from_nano_tsopt")]
259
260
/// time: Option<NaiveDateTime>
260
261
/// }
261
262
///
262
263
/// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918355733 }"#)?;
264
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1526522699, 918355733) });
263
265
/// # Ok::<(), serde_json::Error>(())
264
266
/// ```
265
267
#[ must_use]
@@ -378,13 +380,14 @@ pub mod ts_microseconds {
378
380
/// # use chrono::NaiveDateTime;
379
381
/// # use serde_derive::Deserialize;
380
382
/// use chrono::naive::serde::ts_microseconds::deserialize as from_micro_ts;
381
- /// #[derive(Deserialize)]
383
+ /// #[derive(Debug, PartialEq, Deserialize)]
382
384
/// struct S {
383
385
/// #[serde(deserialize_with = "from_micro_ts")]
384
386
/// time: NaiveDateTime
385
387
/// }
386
388
///
387
389
/// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918355 }"#)?;
390
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1526522699, 918355000).unwrap() });
388
391
/// # Ok::<(), serde_json::Error>(())
389
392
/// ```
390
393
#[ must_use]
@@ -506,13 +509,14 @@ pub mod ts_microseconds_option {
506
509
/// # use chrono::naive::NaiveDateTime;
507
510
/// # use serde_derive::Deserialize;
508
511
/// use chrono::naive::serde::ts_microseconds_option::deserialize as from_micro_tsopt;
509
- /// #[derive(Deserialize)]
512
+ /// #[derive(Debug, PartialEq, Deserialize)]
510
513
/// struct S {
511
514
/// #[serde(deserialize_with = "from_micro_tsopt")]
512
515
/// time: Option<NaiveDateTime>
513
516
/// }
514
517
///
515
518
/// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918355 }"#)?;
519
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1526522699, 918355000) });
516
520
/// # Ok::<(), serde_json::Error>(())
517
521
/// ```
518
522
#[ must_use]
@@ -631,13 +635,14 @@ pub mod ts_milliseconds {
631
635
/// # use chrono::NaiveDateTime;
632
636
/// # use serde_derive::Deserialize;
633
637
/// use chrono::naive::serde::ts_milliseconds::deserialize as from_milli_ts;
634
- /// #[derive(Deserialize)]
638
+ /// #[derive(Debug, PartialEq, Deserialize)]
635
639
/// struct S {
636
640
/// #[serde(deserialize_with = "from_milli_ts")]
637
641
/// time: NaiveDateTime
638
642
/// }
639
643
///
640
644
/// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918 }"#)?;
645
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1526522699, 918000000).unwrap() });
641
646
/// # Ok::<(), serde_json::Error>(())
642
647
/// ```
643
648
#[ must_use]
@@ -746,7 +751,7 @@ pub mod ts_milliseconds_option {
746
751
}
747
752
}
748
753
749
- /// Deserialize a `NaiveDateTime` from a nanosecond timestamp or none
754
+ /// Deserialize a `NaiveDateTime` from a millisecond timestamp or none
750
755
///
751
756
/// Intended for use with `serde`s `deserialize_with` attribute.
752
757
///
@@ -756,13 +761,14 @@ pub mod ts_milliseconds_option {
756
761
/// # use chrono::naive::NaiveDateTime;
757
762
/// # use serde_derive::Deserialize;
758
763
/// use chrono::naive::serde::ts_milliseconds_option::deserialize as from_milli_tsopt;
759
- /// #[derive(Deserialize)]
764
+ /// #[derive(Debug, PartialEq, Deserialize)]
760
765
/// struct S {
761
766
/// #[serde(deserialize_with = "from_milli_tsopt")]
762
767
/// time: Option<NaiveDateTime>
763
768
/// }
764
769
///
765
- /// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918355 }"#)?;
770
+ /// let my_s: S = serde_json::from_str(r#"{ "time": 1526522699918 }"#)?;
771
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1526522699, 918000000) });
766
772
/// # Ok::<(), serde_json::Error>(())
767
773
/// ```
768
774
#[ must_use]
@@ -881,13 +887,14 @@ pub mod ts_seconds {
881
887
/// # use chrono::NaiveDateTime;
882
888
/// # use serde_derive::Deserialize;
883
889
/// use chrono::naive::serde::ts_seconds::deserialize as from_ts;
884
- /// #[derive(Deserialize)]
890
+ /// #[derive(Debug, PartialEq, Deserialize)]
885
891
/// struct S {
886
892
/// #[serde(deserialize_with = "from_ts")]
887
893
/// time: NaiveDateTime
888
894
/// }
889
895
///
890
896
/// let my_s: S = serde_json::from_str(r#"{ "time": 1431684000 }"#)?;
897
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1431684000, 0).unwrap() });
891
898
/// # Ok::<(), serde_json::Error>(())
892
899
/// ```
893
900
#[ must_use]
@@ -1003,13 +1010,14 @@ pub mod ts_seconds_option {
1003
1010
/// # use chrono::naive::NaiveDateTime;
1004
1011
/// # use serde_derive::Deserialize;
1005
1012
/// use chrono::naive::serde::ts_seconds_option::deserialize as from_tsopt;
1006
- /// #[derive(Deserialize)]
1013
+ /// #[derive(Debug, PartialEq, Deserialize)]
1007
1014
/// struct S {
1008
1015
/// #[serde(deserialize_with = "from_tsopt")]
1009
1016
/// time: Option<NaiveDateTime>
1010
1017
/// }
1011
1018
///
1012
1019
/// let my_s: S = serde_json::from_str(r#"{ "time": 1431684000 }"#)?;
1020
+ /// assert_eq!(my_s, S { time: NaiveDateTime::from_timestamp_opt(1431684000, 0) });
1013
1021
/// # Ok::<(), serde_json::Error>(())
1014
1022
/// ```
1015
1023
#[ must_use]
0 commit comments