• Home
  • Raw
  • Download

Lines Matching +full:rkyv +full:- +full:validation

9 #[cfg(any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))]
10 use rkyv::{Archive, Deserialize, Serialize};
16 /// The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59.
24 any(feature = "rkyv", feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"),
29 #[cfg_attr(feature = "rkyv-validation", archive(check_bytes))]
38 /// Panics on the out-of-bound `secs`.
41 pub fn east(secs: i32) -> FixedOffset { in east()
48 /// Returns `None` on the out-of-bound `secs`.
60 /// assert_eq!(&datetime.to_rfc3339(), "2016-11-08T00:00:00+05:00")
63 pub const fn east_opt(secs: i32) -> Option<FixedOffset> { in east_opt()
64 if -86_400 < secs && secs < 86_400 { in east_opt()
74 /// Panics on the out-of-bound `secs`.
77 pub fn west(secs: i32) -> FixedOffset { in west()
84 /// Returns `None` on the out-of-bound `secs`.
96 /// assert_eq!(&datetime.to_rfc3339(), "2016-11-08T00:00:00-05:00")
99 pub const fn west_opt(secs: i32) -> Option<FixedOffset> { in west_opt()
100 if -86_400 < secs && secs < 86_400 { in west_opt()
101 Some(FixedOffset { local_minus_utc: -secs }) in west_opt()
109 pub const fn local_minus_utc(&self) -> i32 { in local_minus_utc()
115 pub const fn utc_minus_local(&self) -> i32 { in utc_minus_local()
116 -self.local_minus_utc in utc_minus_local()
123 fn from_str(s: &str) -> Result<Self, Self::Err> { in from_str()
132 fn from_offset(offset: &FixedOffset) -> FixedOffset { in from_offset()
136 fn offset_from_local_date(&self, _local: &NaiveDate) -> LocalResult<FixedOffset> { in offset_from_local_date()
139 fn offset_from_local_datetime(&self, _local: &NaiveDateTime) -> LocalResult<FixedOffset> { in offset_from_local_datetime()
143 fn offset_from_utc_date(&self, _utc: &NaiveDate) -> FixedOffset { in offset_from_utc_date()
146 fn offset_from_utc_datetime(&self, _utc: &NaiveDateTime) -> FixedOffset { in offset_from_utc_datetime()
152 fn fix(&self) -> FixedOffset { in fix()
158 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
160 let (sign, offset) = if offset < 0 { ('-', -offset) } else { ('+', offset) }; in fmt()
174 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
181 fn arbitrary(u: &mut arbitrary::Unstructured) -> arbitrary::Result<FixedOffset> { in arbitrary()
182 let secs = u.int_in_range(-86_399..=86_399)?; in arbitrary()
202 "2012-02-29T05:06:07+23:59:59" in test_date_extreme_offset()
204 let offset = FixedOffset::east_opt(-86399).unwrap(); in test_date_extreme_offset()
207 "2012-02-29T05:06:07-23:59:59" in test_date_extreme_offset()
212 "2012-03-04T05:06:07-23:59:59" in test_date_extreme_offset()
214 let offset = FixedOffset::west_opt(-86399).unwrap(); in test_date_extreme_offset()
217 "2012-03-04T05:06:07+23:59:59" in test_date_extreme_offset()
223 let offset = FixedOffset::from_str("-0500").unwrap(); in test_parse_offset()
224 assert_eq!(offset.local_minus_utc, -5 * 3600); in test_parse_offset()
225 let offset = FixedOffset::from_str("-08:00").unwrap(); in test_parse_offset()
226 assert_eq!(offset.local_minus_utc, -8 * 3600); in test_parse_offset()
232 #[cfg(feature = "rkyv-validation")]
234 let offset = FixedOffset::from_str("-0500").unwrap(); in test_rkyv_validation()
235 let bytes = rkyv::to_bytes::<_, 4>(&offset).unwrap(); in test_rkyv_validation()
236 assert_eq!(rkyv::from_bytes::<FixedOffset>(&bytes).unwrap(), offset); in test_rkyv_validation()