• Home
  • Raw
  • Download

Lines Matching +full:test +full:- +full:serde

10 #[cfg(any(feature = "std", test))]
18 #[cfg(any(feature = "alloc", feature = "std", test))]
20 #[cfg(any(feature = "alloc", feature = "std", test))]
22 #[cfg(feature = "unstable-locales")]
55 /// display all available non-zero sub-second digits. This corresponds to
67 /// the general-purpose constructors are all via the methods on the
95 pub fn from_utc(datetime: NaiveDateTime, offset: Tz::Offset) -> DateTime<Tz> { in from_utc()
101 pub fn date(&self) -> Date<Tz> { in date()
108 pub fn time(&self) -> NaiveTime { in time()
112 /// Returns the number of non-leap seconds since January 1, 1970 0:00:00 UTC
115 pub fn timestamp(&self) -> i64 { in timestamp()
119 /// Returns the number of non-leap-milliseconds since January 1, 1970 UTC
139 pub fn timestamp_millis(&self) -> i64 { in timestamp_millis()
143 /// Returns the number of non-leap-nanoseconds since January 1, 1970 UTC
163 pub fn timestamp_nanos(&self) -> i64 { in timestamp_nanos()
173 pub fn timestamp_subsec_millis(&self) -> u32 { in timestamp_subsec_millis()
183 pub fn timestamp_subsec_micros(&self) -> u32 { in timestamp_subsec_micros()
193 pub fn timestamp_subsec_nanos(&self) -> u32 { in timestamp_subsec_nanos()
199 pub fn offset(&self) -> &Tz::Offset { in offset()
205 pub fn timezone(&self) -> Tz { in timezone()
212 pub fn with_timezone<Tz2: TimeZone>(&self, tz: &Tz2) -> DateTime<Tz2> { in with_timezone()
220 pub fn checked_add_signed(self, rhs: OldDuration) -> Option<DateTime<Tz>> { in checked_add_signed()
230 pub fn checked_sub_signed(self, rhs: OldDuration) -> Option<DateTime<Tz>> { in checked_sub_signed()
239 pub fn signed_duration_since<Tz2: TimeZone>(self, rhs: DateTime<Tz2>) -> OldDuration { in signed_duration_since()
245 pub fn naive_utc(&self) -> NaiveDateTime { in naive_utc()
251 pub fn naive_local(&self) -> NaiveDateTime { in naive_local()
262 fn from(src: DateTime<Utc>) -> Self { in from()
273 fn from(src: DateTime<Utc>) -> Self { in from()
284 fn from(src: DateTime<FixedOffset>) -> Self { in from()
296 fn from(src: DateTime<FixedOffset>) -> Self { in from()
308 fn from(src: DateTime<Local>) -> Self { in from()
320 fn from(src: DateTime<Local>) -> Self { in from()
326 fn map_local<Tz: TimeZone, F>(dt: &DateTime<Tz>, mut f: F) -> Option<DateTime<Tz>> in map_local()
328 F: FnMut(NaiveDateTime) -> Option<NaiveDateTime>, in map_local()
347 pub fn parse_from_rfc2822(s: &str) -> ParseResult<DateTime<FixedOffset>> { in parse_from_rfc2822()
354 /// Parses an RFC 3339 and ISO 8601 date and time string such as `1996-12-19T16:39:57-08:00`,
359 pub fn parse_from_rfc3339(s: &str) -> ParseResult<DateTime<FixedOffset>> { in parse_from_rfc3339()
375 /// for a version that does not require a timezone in the to-be-parsed str.
386 pub fn parse_from_str(s: &str, fmt: &str) -> ParseResult<DateTime<FixedOffset>> { in parse_from_str()
398 #[cfg(any(feature = "alloc", feature = "std", test))]
399 pub fn to_rfc2822(&self) -> String { in to_rfc2822()
404 /// Returns an RFC 3339 and ISO 8601 date and time string such as `1996-12-19T16:39:57-08:00`.
405 #[cfg(any(feature = "alloc", feature = "std", test))]
406 pub fn to_rfc3339(&self) -> String { in to_rfc3339()
424 /// "2018-01-26T18:30:09.453+00:00");
426 /// "2018-01-26T18:30:09.453Z");
428 /// "2018-01-26T18:30:09Z");
433 /// "2018-01-26T10:30:09+08:00");
435 #[cfg(any(feature = "alloc", feature = "std", test))]
436 pub fn to_rfc3339_opts(&self, secform: SecondsFormat, use_z: bool) -> String { in to_rfc3339_opts()
445 Item::Literal("-"), in to_rfc3339_opts()
447 Item::Literal("-"), in to_rfc3339_opts()
479 #[cfg(any(feature = "alloc", feature = "std", test))]
481 pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I> in format_with_items()
493 #[cfg(any(feature = "alloc", feature = "std", test))]
495 pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>> { in format()
500 #[cfg(feature = "unstable-locales")]
506 ) -> DelayedFormat<I> in format_localized_with_items()
524 #[cfg(feature = "unstable-locales")]
530 ) -> DelayedFormat<StrftimeItems<'a>> { in format_localized()
537 fn year(&self) -> i32 { in year()
541 fn month(&self) -> u32 { in month()
545 fn month0(&self) -> u32 { in month0()
549 fn day(&self) -> u32 { in day()
553 fn day0(&self) -> u32 { in day0()
557 fn ordinal(&self) -> u32 { in ordinal()
561 fn ordinal0(&self) -> u32 { in ordinal0()
565 fn weekday(&self) -> Weekday { in weekday()
569 fn iso_week(&self) -> IsoWeek { in iso_week()
574 fn with_year(&self, year: i32) -> Option<DateTime<Tz>> { in with_year()
579 fn with_month(&self, month: u32) -> Option<DateTime<Tz>> { in with_month()
584 fn with_month0(&self, month0: u32) -> Option<DateTime<Tz>> { in with_month0()
589 fn with_day(&self, day: u32) -> Option<DateTime<Tz>> { in with_day()
594 fn with_day0(&self, day0: u32) -> Option<DateTime<Tz>> { in with_day0()
599 fn with_ordinal(&self, ordinal: u32) -> Option<DateTime<Tz>> { in with_ordinal()
604 fn with_ordinal0(&self, ordinal0: u32) -> Option<DateTime<Tz>> { in with_ordinal0()
611 fn hour(&self) -> u32 { in hour()
615 fn minute(&self) -> u32 { in minute()
619 fn second(&self) -> u32 { in second()
623 fn nanosecond(&self) -> u32 { in nanosecond()
628 fn with_hour(&self, hour: u32) -> Option<DateTime<Tz>> { in with_hour()
633 fn with_minute(&self, min: u32) -> Option<DateTime<Tz>> { in with_minute()
638 fn with_second(&self, sec: u32) -> Option<DateTime<Tz>> { in with_second()
643 fn with_nanosecond(&self, nano: u32) -> Option<DateTime<Tz>> { in with_nanosecond()
653 fn eq(&self, other: &DateTime<Tz2>) -> bool { in eq()
671 /// assert_eq!(earlier.to_string(), "2015-05-15 01:00:00 -01:00");
672 /// assert_eq!(later.to_string(), "2015-05-14 22:00:00 -05:00");
676 fn partial_cmp(&self, other: &DateTime<Tz2>) -> Option<Ordering> { in partial_cmp()
682 fn cmp(&self, other: &DateTime<Tz>) -> Ordering { in cmp()
697 fn add(self, rhs: OldDuration) -> DateTime<Tz> { in add()
706 fn sub(self, rhs: OldDuration) -> DateTime<Tz> { in sub()
707 self.checked_sub_signed(rhs).expect("`DateTime - Duration` overflowed") in sub()
715 fn sub(self, rhs: DateTime<Tz>) -> OldDuration { in sub()
721 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
730 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
738 fn from_str(s: &str) -> ParseResult<DateTime<Utc>> { in from_str()
747 fn from_str(s: &str) -> ParseResult<DateTime<Local>> { in from_str()
752 #[cfg(any(feature = "std", test))]
754 fn from(t: SystemTime) -> DateTime<Utc> { in from()
762 (-sec, 0) in from()
764 (-sec - 1, 1_000_000_000 - nsec) in from()
774 fn from(t: SystemTime) -> DateTime<Local> { in from()
779 #[cfg(any(feature = "std", test))]
781 fn from(dt: DateTime<Tz>) -> SystemTime { in from()
788 UNIX_EPOCH - Duration::new(-sec as u64, 0) + Duration::new(0, nsec) in from()
797 fn from(date: js_sys::Date) -> DateTime<Utc> { in from()
804 fn from(date: &js_sys::Date) -> DateTime<Utc> { in from()
815 fn from(date: DateTime<Utc>) -> js_sys::Date { in from()
832 #[test]
840 #[cfg(all(test, any(feature = "rustc-serialize", feature = "serde")))]
843 FUtc: Fn(&DateTime<Utc>) -> Result<String, E>, in test_encodable_json()
844 FFixed: Fn(&DateTime<FixedOffset>) -> Result<String, E>, in test_encodable_json()
849 Some(r#""2014-07-24T12:34:06Z""#.into()) in test_encodable_json()
854 Some(r#""2014-07-24T12:34:06+01:01""#.into()) in test_encodable_json()
858 Some(r#""2014-07-24T12:34:06+01:00:50""#.into()) in test_encodable_json()
862 #[cfg(all(test, feature = "clock", any(feature = "rustc-serialize", feature = "serde")))]
868 FUtc: Fn(&str) -> Result<DateTime<Utc>, E>, in test_decodable_json()
869 FFixed: Fn(&str) -> Result<DateTime<FixedOffset>, E>, in test_decodable_json()
870 FLocal: Fn(&str) -> Result<DateTime<Local>, E>, in test_decodable_json()
874 fn norm<Tz: TimeZone>(dt: &Option<DateTime<Tz>>) -> Option<(&DateTime<Tz>, &Tz::Offset)> { in test_decodable_json()
879 norm(&utc_from_str(r#""2014-07-24T12:34:06Z""#).ok()), in test_decodable_json()
883 norm(&utc_from_str(r#""2014-07-24T13:57:06+01:23""#).ok()), in test_decodable_json()
888 norm(&fixed_from_str(r#""2014-07-24T12:34:06Z""#).ok()), in test_decodable_json()
892 norm(&fixed_from_str(r#""2014-07-24T13:57:06+01:23""#).ok()), in test_decodable_json()
899 local_from_str(r#""2014-07-24T12:34:06Z""#).expect("local shouuld parse"), in test_decodable_json()
903 local_from_str(r#""2014-07-24T13:57:06+01:23""#).expect("local should parse with offset"), in test_decodable_json()
907 assert!(utc_from_str(r#""2014-07-32T12:34:06Z""#).is_err()); in test_decodable_json()
908 assert!(fixed_from_str(r#""2014-07-32T12:34:06Z""#).is_err()); in test_decodable_json()
911 #[cfg(all(test, feature = "clock", feature = "rustc-serialize"))]
917 FUtc: Fn(&str) -> Result<rustc_serialize::TsSeconds<Utc>, E>, in test_decodable_json_timestamps()
918 FFixed: Fn(&str) -> Result<rustc_serialize::TsSeconds<FixedOffset>, E>, in test_decodable_json_timestamps()
919 FLocal: Fn(&str) -> Result<rustc_serialize::TsSeconds<Local>, E>, in test_decodable_json_timestamps()
922 fn norm<Tz: TimeZone>(dt: &Option<DateTime<Tz>>) -> Option<(&DateTime<Tz>, &Tz::Offset)> { in test_decodable_json_timestamps()
931 norm(&utc_from_str("-1").ok().map(DateTime::from)), in test_decodable_json_timestamps()
940 norm(&fixed_from_str("-1").ok().map(DateTime::from)), in test_decodable_json_timestamps()
949 *local_from_str("-1").expect("-1 timestamp should parse"), in test_decodable_json_timestamps()
954 #[cfg(feature = "rustc-serialize")]
965 fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { in encode()
970 // lik? function to convert a LocalResult into a serde-ish Result
971 fn from<T, D>(me: LocalResult<T>, d: &mut D) -> Result<T, D::Error> in from()
984 fn decode<D: Decoder>(d: &mut D) -> Result<DateTime<FixedOffset>, D::Error> { in decode()
994 fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<FixedOffset>, D::Error> { in decode()
1000 fn decode<D: Decoder>(d: &mut D) -> Result<DateTime<Utc>, D::Error> { in decode()
1018 fn from(obj: TsSeconds<Tz>) -> DateTime<Tz> { in from()
1027 fn deref(&self) -> &Self::Target { in deref()
1034 fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<Utc>, D::Error> { in decode()
1041 fn decode<D: Decoder>(d: &mut D) -> Result<DateTime<Local>, D::Error> { in decode()
1053 fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<Local>, D::Error> { in decode()
1059 #[cfg(test)]
1062 #[test]
1068 #[test]
1074 #[test]
1080 /// documented at re-export site
1081 #[cfg(feature = "serde")]
1082 pub mod serde { module
1103 // lik? function to convert a LocalResult into a serde-ish Result
1104 fn serde_from<T, E, V>(me: LocalResult<T>, ts: &V) -> Result<T, E> in serde_from()
1121 /// Intended for use with `serde`'s `with` attribute.
1126 /// # // We mark this ignored so that we can test on 1.13 (which does not
1127 /// # // support custom derive), and run tests with --ignored on beta and
1134 /// use chrono::serde::ts_nanoseconds;
1137 /// #[serde(with = "ts_nanoseconds")]
1141 /// # fn example() -> Result<S, serde_json::Error> {
1166 /// Intended for use with `serde`s `serialize_with` attribute.
1171 /// # // We mark this ignored so that we can test on 1.13 (which does not
1172 /// # // support custom derive), and run tests with --ignored on beta and
1179 /// use chrono::serde::ts_nanoseconds::serialize as to_nano_ts;
1182 /// #[serde(serialize_with = "to_nano_ts")]
1186 /// # fn example() -> Result<String, serde_json::Error> {
1196 pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error> in serialize()
1205 /// Intended for use with `serde`s `deserialize_with` attribute.
1210 /// # // We mark this ignored so that we can test on 1.13 (which does not
1211 /// # // support custom derive), and run tests with --ignored on beta and
1218 /// use chrono::serde::ts_nanoseconds::deserialize as from_nano_ts;
1221 /// #[serde(deserialize_with = "from_nano_ts")]
1225 /// # fn example() -> Result<S, serde_json::Error> {
1231 pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error> in deserialize()
1241 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
1246 fn visit_i64<E>(self, value: i64) -> Result<DateTime<Utc>, E> in visit_i64()
1257 fn visit_u64<E>(self, value: u64) -> Result<DateTime<Utc>, E> in visit_u64()
1274 /// Intended for use with `serde`'s `with` attribute.
1279 /// # // We mark this ignored so that we can test on 1.13 (which does not
1280 /// # // support custom derive), and run tests with --ignored on beta and
1287 /// use chrono::serde::ts_nanoseconds_option;
1290 /// #[serde(with = "ts_nanoseconds_option")]
1294 /// # fn example() -> Result<S, serde_json::Error> {
1318 /// Intended for use with `serde`s `serialize_with` attribute.
1323 /// # // We mark this ignored so that we can test on 1.13 (which does not
1324 /// # // support custom derive), and run tests with --ignored on beta and
1331 /// use chrono::serde::ts_nanoseconds_option::serialize as to_nano_tsopt;
1334 /// #[serde(serialize_with = "to_nano_tsopt")]
1338 /// # fn example() -> Result<String, serde_json::Error> {
1348 pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error> in serialize()
1360 /// Intended for use with `serde`s `deserialize_with` attribute.
1365 /// # // We mark this ignored so that we can test on 1.13 (which does not
1366 /// # // support custom derive), and run tests with --ignored on beta and
1373 /// use chrono::serde::ts_nanoseconds_option::deserialize as from_nano_tsopt;
1376 /// #[serde(deserialize_with = "from_nano_tsopt")]
1380 /// # fn example() -> Result<S, serde_json::Error> {
1386 pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error> in deserialize()
1398 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
1403 fn visit_some<D>(self, d: D) -> Result<Option<DateTime<Utc>>, D::Error> in visit_some()
1411 fn visit_none<E>(self) -> Result<Option<DateTime<Utc>>, E> in visit_none()
1419 fn visit_unit<E>(self) -> Result<Option<DateTime<Utc>>, E> in visit_unit()
1430 /// Intended for use with `serde`s `with` attribute.
1435 /// # // We mark this ignored so that we can test on 1.13 (which does not
1436 /// # // support custom derive), and run tests with --ignored on beta and
1443 /// use chrono::serde::ts_milliseconds;
1446 /// #[serde(with = "ts_milliseconds")]
1450 /// # fn example() -> Result<S, serde_json::Error> {
1475 /// Intended for use with `serde`s `serialize_with` attribute.
1480 /// # // We mark this ignored so that we can test on 1.13 (which does not
1481 /// # // support custom derive), and run tests with --ignored on beta and
1488 /// use chrono::serde::ts_milliseconds::serialize as to_milli_ts;
1491 /// #[serde(serialize_with = "to_milli_ts")]
1495 /// # fn example() -> Result<String, serde_json::Error> {
1505 pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error> in serialize()
1514 /// Intended for use with `serde`s `deserialize_with` attribute.
1519 /// # // We mark this ignored so that we can test on 1.13 (which does not
1520 /// # // support custom derive), and run tests with --ignored on beta and
1527 /// use chrono::serde::ts_milliseconds::deserialize as from_milli_ts;
1530 /// #[serde(deserialize_with = "from_milli_ts")]
1534 /// # fn example() -> Result<S, serde_json::Error> {
1540 pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error> in deserialize()
1550 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
1555 fn visit_i64<E>(self, value: i64) -> Result<DateTime<Utc>, E> in visit_i64()
1566 fn visit_u64<E>(self, value: u64) -> Result<DateTime<Utc>, E> in visit_u64()
1580 /// Intended for use with `serde`s `with` attribute.
1585 /// # // We mark this ignored so that we can test on 1.13 (which does not
1586 /// # // support custom derive), and run tests with --ignored on beta and
1593 /// use chrono::serde::ts_milliseconds_option;
1596 /// #[serde(with = "ts_milliseconds_option")]
1600 /// # fn example() -> Result<S, serde_json::Error> {
1624 /// Intended for use with `serde`s `serialize_with` attribute.
1629 /// # // We mark this ignored so that we can test on 1.13 (which does not
1630 /// # // support custom derive), and run tests with --ignored on beta and
1637 /// use chrono::serde::ts_milliseconds_option::serialize as to_milli_tsopt;
1640 /// #[serde(serialize_with = "to_milli_tsopt")]
1644 /// # fn example() -> Result<String, serde_json::Error> {
1654 pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error> in serialize()
1666 /// Intended for use with `serde`s `deserialize_with` attribute.
1671 /// # // We mark this ignored so that we can test on 1.13 (which does not
1672 /// # // support custom derive), and run tests with --ignored on beta and
1679 /// use chrono::serde::ts_milliseconds_option::deserialize as from_milli_tsopt;
1682 /// #[serde(untagged)]
1689 /// #[serde(default, deserialize_with = "from_milli_tsopt")]
1693 /// # fn example() -> Result<(), serde_json::Error> {
1704 pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error> in deserialize()
1717 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
1722 fn visit_some<D>(self, d: D) -> Result<Option<DateTime<Utc>>, D::Error> in visit_some()
1730 fn visit_none<E>(self) -> Result<Option<DateTime<Utc>>, E> in visit_none()
1738 fn visit_unit<E>(self) -> Result<Option<DateTime<Utc>>, E> in visit_unit()
1749 /// Intended for use with `serde`'s `with` attribute.
1754 /// # // We mark this ignored so that we can test on 1.13 (which does not
1755 /// # // support custom derive), and run tests with --ignored on beta and
1762 /// use chrono::serde::ts_seconds;
1765 /// #[serde(with = "ts_seconds")]
1769 /// # fn example() -> Result<S, serde_json::Error> {
1794 /// Intended for use with `serde`s `serialize_with` attribute.
1799 /// # // We mark this ignored so that we can test on 1.13 (which does not
1800 /// # // support custom derive), and run tests with --ignored on beta and
1807 /// use chrono::serde::ts_seconds::serialize as to_ts;
1810 /// #[serde(serialize_with = "to_ts")]
1814 /// # fn example() -> Result<String, serde_json::Error> {
1824 pub fn serialize<S>(dt: &DateTime<Utc>, serializer: S) -> Result<S::Ok, S::Error> in serialize()
1833 /// Intended for use with `serde`s `deserialize_with` attribute.
1838 /// # // We mark this ignored so that we can test on 1.13 (which does not
1839 /// # // support custom derive), and run tests with --ignored on beta and
1846 /// use chrono::serde::ts_seconds::deserialize as from_ts;
1849 /// #[serde(deserialize_with = "from_ts")]
1853 /// # fn example() -> Result<S, serde_json::Error> {
1859 pub fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error> in deserialize()
1869 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
1874 fn visit_i64<E>(self, value: i64) -> Result<DateTime<Utc>, E> in visit_i64()
1882 fn visit_u64<E>(self, value: u64) -> Result<DateTime<Utc>, E> in visit_u64()
1893 /// Intended for use with `serde`'s `with` attribute.
1898 /// # // We mark this ignored so that we can test on 1.13 (which does not
1899 /// # // support custom derive), and run tests with --ignored on beta and
1906 /// use chrono::serde::ts_seconds_option;
1909 /// #[serde(with = "ts_seconds_option")]
1913 /// # fn example() -> Result<S, serde_json::Error> {
1937 /// Intended for use with `serde`s `serialize_with` attribute.
1942 /// # // We mark this ignored so that we can test on 1.13 (which does not
1943 /// # // support custom derive), and run tests with --ignored on beta and
1950 /// use chrono::serde::ts_seconds_option::serialize as to_tsopt;
1953 /// #[serde(serialize_with = "to_tsopt")]
1957 /// # fn example() -> Result<String, serde_json::Error> {
1967 pub fn serialize<S>(opt: &Option<DateTime<Utc>>, serializer: S) -> Result<S::Ok, S::Error> in serialize()
1979 /// Intended for use with `serde`s `deserialize_with` attribute.
1984 /// # // We mark this ignored so that we can test on 1.13 (which does not
1985 /// # // support custom derive), and run tests with --ignored on beta and
1992 /// use chrono::serde::ts_seconds_option::deserialize as from_tsopt;
1995 /// #[serde(deserialize_with = "from_tsopt")]
1999 /// # fn example() -> Result<S, serde_json::Error> {
2005 pub fn deserialize<'de, D>(d: D) -> Result<Option<DateTime<Utc>>, D::Error> in deserialize()
2017 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
2022 fn visit_some<D>(self, d: D) -> Result<Option<DateTime<Utc>>, D::Error> in visit_some()
2030 fn visit_none<E>(self) -> Result<Option<DateTime<Utc>>, E> in visit_none()
2038 fn visit_unit<E>(self) -> Result<Option<DateTime<Utc>>, E> in visit_unit()
2050 /// See [the `serde` module](./serde/index.html) for alternate
2052 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> in serialize()
2061 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in serialize()
2076 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in expecting()
2080 fn visit_str<E>(self, value: &str) -> Result<DateTime<FixedOffset>, E> in visit_str()
2093 /// See [the `serde` module](./serde/index.html) for alternate
2096 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> in deserialize()
2108 /// See [the `serde` module](./serde/index.html) for alternate
2111 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> in deserialize()
2124 /// See [the `serde` module](./serde/index.html) for alternate
2128 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> in deserialize()
2136 #[cfg(test)]
2138 #[cfg(test)]
2141 #[test]
2147 #[test]
2156 #[test]
2158 // Bincode is relevant to test separately from JSON because in test_serde_bincode()
2159 // it is not self-describing. in test_serde_bincode()
2170 #[cfg(test)]
2182 #[test]
2189 assert_eq!(format!("{}", Utc.ymd(2014, 5, 6).and_hms(7, 8, 9)), "2014-05-06 07:08:09 UTC"); in test_datetime_offset()
2192 "2014-05-06 07:08:09 -04:00" in test_datetime_offset()
2196 "2014-05-06 07:08:09 +09:00" in test_datetime_offset()
2198 assert_eq!(format!("{:?}", Utc.ymd(2014, 5, 6).and_hms(7, 8, 9)), "2014-05-06T07:08:09Z"); in test_datetime_offset()
2201 "2014-05-06T07:08:09-04:00" in test_datetime_offset()
2205 "2014-05-06T07:08:09+09:00" in test_datetime_offset()
2209 assert_eq!(format!("{:?}", Utc.ymd(2014, 5, 6).and_hms(0, 0, 0)), "2014-05-06T00:00:00Z"); in test_datetime_offset()
2212 "2014-05-06T00:00:00-04:00" in test_datetime_offset()
2216 "2014-05-06T00:00:00+09:00" in test_datetime_offset()
2220 "2014-05-06T23:59:59Z" in test_datetime_offset()
2224 "2014-05-06T23:59:59-04:00" in test_datetime_offset()
2228 "2014-05-06T23:59:59+09:00" in test_datetime_offset()
2236 Duration::seconds(-7 * 3600 - 3 * 60 - 3) in test_datetime_offset()
2244 #[test]
2271 #[test]
2280 #[test]
2290 "2015-02-18T23:16:09+00:00" in test_datetime_rfc2822_and_rfc3339()
2298 "2015-02-18T23:16:09.150+05:00" in test_datetime_rfc2822_and_rfc3339()
2306 "2015-02-18T23:59:60.234567+05:00" in test_datetime_rfc2822_and_rfc3339()
2314 DateTime::parse_from_rfc2822("Wed, 18 Feb 2015 23:16:09 -0000"), in test_datetime_rfc2822_and_rfc3339()
2318 DateTime::parse_from_rfc3339("2015-02-18T23:16:09Z"), in test_datetime_rfc2822_and_rfc3339()
2326 DateTime::parse_from_rfc3339("2015-02-18T23:59:60.234567+05:00"), in test_datetime_rfc2822_and_rfc3339()
2331 #[test]
2336 assert_eq!(dt.to_rfc3339_opts(Secs, false), "2018-01-11T10:05:13+08:00"); in test_rfc3339_opts()
2337 assert_eq!(dt.to_rfc3339_opts(Secs, true), "2018-01-11T10:05:13+08:00"); in test_rfc3339_opts()
2338 assert_eq!(dt.to_rfc3339_opts(Millis, false), "2018-01-11T10:05:13.084+08:00"); in test_rfc3339_opts()
2339 assert_eq!(dt.to_rfc3339_opts(Micros, false), "2018-01-11T10:05:13.084660+08:00"); in test_rfc3339_opts()
2340 assert_eq!(dt.to_rfc3339_opts(Nanos, false), "2018-01-11T10:05:13.084660000+08:00"); in test_rfc3339_opts()
2341 assert_eq!(dt.to_rfc3339_opts(AutoSi, false), "2018-01-11T10:05:13.084660+08:00"); in test_rfc3339_opts()
2344 assert_eq!(ut.to_rfc3339_opts(Secs, false), "2018-01-11T02:05:13+00:00"); in test_rfc3339_opts()
2345 assert_eq!(ut.to_rfc3339_opts(Secs, true), "2018-01-11T02:05:13Z"); in test_rfc3339_opts()
2346 assert_eq!(ut.to_rfc3339_opts(Millis, false), "2018-01-11T02:05:13.084+00:00"); in test_rfc3339_opts()
2347 assert_eq!(ut.to_rfc3339_opts(Millis, true), "2018-01-11T02:05:13.084Z"); in test_rfc3339_opts()
2348 assert_eq!(ut.to_rfc3339_opts(Micros, true), "2018-01-11T02:05:13.084660Z"); in test_rfc3339_opts()
2349 assert_eq!(ut.to_rfc3339_opts(Nanos, true), "2018-01-11T02:05:13.084660000Z"); in test_rfc3339_opts()
2350 assert_eq!(ut.to_rfc3339_opts(AutoSi, true), "2018-01-11T02:05:13.084660Z"); in test_rfc3339_opts()
2353 #[test]
2361 #[test]
2364 "2015-02-18T23:16:9.15Z".parse::<DateTime<FixedOffset>>(), in test_datetime_from_str()
2368 "2015-02-18T23:16:9.15Z".parse::<DateTime<Utc>>(), in test_datetime_from_str()
2372 "2015-02-18T23:16:9.15 UTC".parse::<DateTime<Utc>>(), in test_datetime_from_str()
2376 "2015-02-18T23:16:9.15UTC".parse::<DateTime<Utc>>(), in test_datetime_from_str()
2381 "2015-2-18T23:16:9.15Z".parse::<DateTime<FixedOffset>>(), in test_datetime_from_str()
2385 "2015-2-18T13:16:9.15-10:00".parse::<DateTime<FixedOffset>>(), in test_datetime_from_str()
2388 assert!("2015-2-18T23:16:9.15".parse::<DateTime<FixedOffset>>().is_err()); in test_datetime_from_str()
2391 "2015-2-18T23:16:9.15Z".parse::<DateTime<Utc>>(), in test_datetime_from_str()
2395 "2015-2-18T13:16:9.15-10:00".parse::<DateTime<Utc>>(), in test_datetime_from_str()
2398 assert!("2015-2-18T23:16:9.15".parse::<DateTime<Utc>>().is_err()); in test_datetime_from_str()
2400 // no test for `DateTime<Local>`, we cannot verify that much. in test_datetime_from_str()
2403 #[test]
2407 DateTime::parse_from_str("2014-5-7T12:34:56+09:30", "%Y-%m-%dT%H:%M:%S%z"), in test_datetime_parse_from_str()
2422 #[test]
2434 #[test]
2441 #[test]
2449 #[test]
2458 #[test]
2472 #[test]
2481 #[test]
2489 // SystemTime -> DateTime<Utc> in test_from_system_time()
2496 DateTime::<Utc>::from(UNIX_EPOCH - Duration::new(999_999_999, nanos)), in test_from_system_time()
2500 // DateTime<Utc> -> SystemTime in test_from_system_time()
2508 UNIX_EPOCH - Duration::new(999_999_999, 999_999_999) in test_from_system_time()
2511 // DateTime<any tz> -> SystemTime (via `with_timezone`) in test_from_system_time()
2520 #[test]
2529 // SystemTime -> DateTime<Utc> in test_from_system_time()
2536 DateTime::<Utc>::from(UNIX_EPOCH - Duration::new(999_999_999, nanos)), in test_from_system_time()
2540 // DateTime<Utc> -> SystemTime in test_from_system_time()
2548 UNIX_EPOCH - Duration::new(999_999_999, nanos) in test_from_system_time()
2551 // DateTime<any tz> -> SystemTime (via `with_timezone`) in test_from_system_time()
2560 #[test]