| 1 | // auto-generated by: jiff-cli generate shared |
| 2 | |
| 3 | /*! |
| 4 | This module defines the internal core time data types. |
| 5 | |
| 6 | This includes physical time (i.e., a timestamp) and civil time. |
| 7 | |
| 8 | These types exist to provide a home for the core algorithms in a datetime |
| 9 | crate. For example, converting from a timestamp to a Gregorian calendar date |
| 10 | and clock time. |
| 11 | |
| 12 | These routines are specifically implemented on simple primitive integer types |
| 13 | and implicitly assume that the inputs are valid (i.e., within Jiff's minimum |
| 14 | and maximum ranges). |
| 15 | |
| 16 | These exist to provide `const` capabilities, and also to provide a small |
| 17 | reusable core of important algorithms that can be shared between `jiff` and |
| 18 | `jiff-static`. |
| 19 | |
| 20 | # Naming |
| 21 | |
| 22 | The types in this module are prefixed with letter `I` to make it clear that |
| 23 | they are internal types. Specifically, to distinguish them from Jiff's public |
| 24 | types. For example, `Date` versus `IDate`. |
| 25 | */ |
| 26 | |
| 27 | use superrust-analyzer cargo jiff-static 0.2.16 shared/util/::errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/::{errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#}; |
| 28 | |
| 29 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 30 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { |
| 31 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#second.: i64, |
| 32 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#nanosecond.: i32, |
| 33 | } |
| 34 | |
| 35 | impl ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { |
| 36 | const MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimestamp]MIN.: ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# = |
| 37 | ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#second.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().377705023201, nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#nanosecond.: 0 }; |
| 38 | const MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimestamp]MAX.: ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# = |
| 39 | ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#second.: 253402207200, nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#nanosecond.: 999_999_999 }; |
| 40 | |
| 41 | /// Creates an `ITimestamp` from a Unix timestamp in seconds. |
| 42 | #[inline] |
| 43 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn from_secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimestamp]from_second().(second: i64) -> ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { |
| 44 | ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#second., nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#nanosecond.: 0 } |
| 45 | } |
| 46 | |
| 47 | /// Converts a Unix timestamp with an offset to a Gregorian datetime. |
| 48 | /// |
| 49 | /// The offset should correspond to the number of seconds required to |
| 50 | /// add to this timestamp to get the local time. |
| 51 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 52 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_datetimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimestamp]to_datetime().(&self, offset: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#) -> IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { |
| 53 | let ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { mut secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#second., mut nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#nanosecond. } = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self; |
| 54 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().offset.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#second. as i64; |
| 55 | let mut epoch_day = second.div_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]div_euclid().(86_400) as i32; |
| 56 | second = second.rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]rem_euclid().(86_400); |
| 57 | if nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 { |
| 58 | if second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialOrd<Self>`]gt().0 { |
| 59 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign().1; |
| 60 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1_000_000_000; |
| 61 | } else { |
| 62 | epoch_day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1; |
| 63 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().86_399; |
| 64 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1_000_000_000; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | let date = IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day. }.to_daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]to_date().(); |
| 69 | let mut time = ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second.: second as i32 }.to_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimeSecond]to_time().(); |
| 70 | time.subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond. = nanosecond; |
| 71 | IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date., timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time. } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 76 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# { |
| 77 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#second.: i32, |
| 78 | } |
| 79 | |
| 80 | impl IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# { |
| 81 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const UTCrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IOffset]UTC.: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# = IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#second.: 0 }; |
| 82 | } |
| 83 | |
| 84 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 85 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { |
| 86 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date.: IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, |
| 87 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time.: ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#, |
| 88 | } |
| 89 | |
| 90 | impl IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { |
| 91 | const MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]MIN.: IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# = IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date.: IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#::MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]MIN., timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time.: ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#::MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]MIN. }; |
| 92 | const MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]MAX.: IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# = IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date.: IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#::MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]MAX., timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time.: ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#::MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]MAX. }; |
| 93 | |
| 94 | /// Converts a Gregorian datetime and its offset to a Unix timestamp. |
| 95 | /// |
| 96 | /// The offset should correspond to the number of seconds required to |
| 97 | /// subtract from this datetime in order to get to UTC. |
| 98 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 99 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn to_timestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]to_timestamp().(&self, offset: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#) -> ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { |
| 100 | let epoch_day = self.daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date..to_epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]to_epoch_day().().epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day.; |
| 101 | let mut second = (epoch_day as i64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().86_400 |
| 102 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().(self.timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time..to_secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]to_second().().secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second. as i64); |
| 103 | let mut nanosecond = self.timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time..subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond.; |
| 104 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`SubAssign<Self>`]sub_assign().offset.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#second. as i64; |
| 105 | if epoch_day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 && nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 { |
| 106 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().1; |
| 107 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1_000_000_000; |
| 108 | } |
| 109 | ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#second., nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#nanosecond. } |
| 110 | } |
| 111 | |
| 112 | /// Converts a Gregorian datetime and its offset to a Unix timestamp. |
| 113 | /// |
| 114 | /// If the timestamp would overflow Jiff's timestamp range, then this |
| 115 | /// returns `None`. |
| 116 | /// |
| 117 | /// The offset should correspond to the number of seconds required to |
| 118 | /// subtract from this datetime in order to get to UTC. |
| 119 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 120 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn to_timestamp_checkedrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]to_timestamp_checked().( |
| 121 | &self, |
| 122 | offset: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#, |
| 123 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#> { |
| 124 | let ts = self.to_timestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]to_timestamp().(offset); |
| 125 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#::MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimestamp]MIN. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().ts && ts rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().ITimestamprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimestamp#::MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimestamp]MAX.) { |
| 126 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 127 | } |
| 128 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ts) |
| 129 | } |
| 130 | |
| 131 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 132 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn saturating_add_secondsrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]saturating_add_seconds().(&self, seconds: i32) -> IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { |
| 133 | self.checked_add_secondsrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]checked_add_seconds().(seconds).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|_| { |
| 134 | if seconds rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 { |
| 135 | IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#::MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]MIN. |
| 136 | } else { |
| 137 | IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#::MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]MAX. |
| 138 | } |
| 139 | }) |
| 140 | } |
| 141 | |
| 142 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 143 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn checked_add_secondsrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDateTime]checked_add_seconds().( |
| 144 | &self, |
| 145 | seconds: i32, |
| 146 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 147 | let day_second = |
| 148 | self.timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time..to_secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]to_second().().secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]checked_add().(seconds).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().( |
| 149 | || errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!("adding `{seconds}s` to datetime overflowed"), |
| 150 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 151 | let days = day_second.div_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]div_euclid().(86400); |
| 152 | let second = day_second.rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]rem_euclid().(86400); |
| 153 | let date = self.daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date..checked_add_daysrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]checked_add_days().(days)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 154 | let time = ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second. }.to_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimeSecond]to_time().(); |
| 155 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date., timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time. }) |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 160 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { |
| 161 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day.: i32, |
| 162 | } |
| 163 | |
| 164 | impl IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { |
| 165 | const MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]MIN.: IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# = IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().4371587 }; |
| 166 | const MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]MAX.: IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# = IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day.: 2932896 }; |
| 167 | |
| 168 | /// Converts days since the Unix epoch to a Gregorian date. |
| 169 | /// |
| 170 | /// This is Neri-Schneider. There's no branching or divisions. |
| 171 | /// |
| 172 | /// Ref: <https://github.com/cassioneri/eaf/blob/684d3cc32d14eee371d0abe4f683d6d6a49ed5c1/algorithms/neri_schneider.hpp#L40C3-L40C34> |
| 173 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 174 | #[allow(non_upper_case_globals, non_snake_case)] // to mimic source |
| 175 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]to_date().(&self) -> IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { |
| 176 | const srust-analyzer cargo jiff-static 0.2.16 shared/util/itime/s.: u32 = 82; |
| 177 | const Krust-analyzer cargo jiff-static 0.2.16 shared/util/itime/K.: u32 = 719468 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().146097 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().srust-analyzer cargo jiff-static 0.2.16 shared/util/itime/s.; |
| 178 | const Lrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/L.: u32 = 400 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().srust-analyzer cargo jiff-static 0.2.16 shared/util/itime/s.; |
| 179 | |
| 180 | let N_U = self.epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day. as u32; |
| 181 | let N = N_U.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(Krust-analyzer cargo jiff-static 0.2.16 shared/util/itime/K.); |
| 182 | |
| 183 | let N_1 = 4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().N rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().3; |
| 184 | let C = N_1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().146097; |
| 185 | let N_C = (N_1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().146097) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().4; |
| 186 | |
| 187 | let N_2 = 4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().N_C rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().3; |
| 188 | let P_2 = 2939745 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().(N_2 as u64); |
| 189 | let Z = (P_2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Div<Self>`]div().4294967296) as u32; |
| 190 | let N_Y = (P_2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Rem<Self>`]rem().4294967296) as u32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().2939745 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().4; |
| 191 | let Y = 100 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().C rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().Z; |
| 192 | |
| 193 | let N_3 = 2141 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().N_Y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().197913; |
| 194 | let M = N_3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().65536; |
| 195 | let D = (N_3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().65536) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().2141; |
| 196 | |
| 197 | let J = N_Y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().306; |
| 198 | let year = Y.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_sub().(Lrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/L.).wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(J as u32) as i16; |
| 199 | let month = (if J { M rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().12 } else { M }) as i8; |
| 200 | let day = (D rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().1) as i8; |
| 201 | IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. } |
| 202 | } |
| 203 | |
| 204 | /// Returns the day of the week for this epoch day. |
| 205 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 206 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]weekday().(&self) -> IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 207 | // Based on Hinnant's approach here, although we use ISO weekday |
| 208 | // numbering by default. Basically, this works by using the knowledge |
| 209 | // that 1970-01-01 was a Thursday. |
| 210 | // |
| 211 | // Ref: http://howardhinnant.github.io/date_algorithms.html |
| 212 | IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_zero_offset().( |
| 213 | (self.epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().3).rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]rem_euclid().(7) as i8 |
| 214 | ) |
| 215 | } |
| 216 | |
| 217 | /// Add the given number of days to this epoch day. |
| 218 | /// |
| 219 | /// If this would overflow an `i32` or result in an out-of-bounds epoch |
| 220 | /// day, then this returns an error. |
| 221 | #[inline] |
| 222 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn checked_addrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]checked_add().(&self, amount: i32) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 223 | let epoch_day = self.epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day.; |
| 224 | let sum = epoch_day.checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]checked_add().(amount).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 225 | errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!("adding `{amount}` to epoch day `{epoch_day}` overflowed i32") |
| 226 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 227 | let ret = IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day.: sum }; |
| 228 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#::MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]MIN. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().ret && ret rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#le().IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#::MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]MAX.) { |
| 229 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 230 | "adding `{amount}` to epoch day `{epoch_day}` \ |
| 231 | resulted in `{sum}`, which is not in the required \ |
| 232 | epoch day range of `{min}..={max}`", |
| 233 | min = IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#::MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]MIN..epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day., |
| 234 | max = IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#::MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]MAX..epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day., |
| 235 | )); |
| 236 | } |
| 237 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ret) |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 242 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { |
| 243 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: i16, |
| 244 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: i8, |
| 245 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: i8, |
| 246 | } |
| 247 | |
| 248 | impl IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { |
| 249 | const MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]MIN.: IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9999, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 250 | const MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]MAX.: IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 9999, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 12, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }; |
| 251 | |
| 252 | /// Fallibly builds a new date. |
| 253 | /// |
| 254 | /// This checks that the given day is valid for the given year/month. |
| 255 | /// |
| 256 | /// No other conditions are checked. This assumes `year` and `month` are |
| 257 | /// valid, and that `day >= 1`. |
| 258 | #[inline] |
| 259 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn try_newrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]try_new().( |
| 260 | year: i16, |
| 261 | month: i8, |
| 262 | day: i8, |
| 263 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 264 | if day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().28 { |
| 265 | let max_day = days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(year, month); |
| 266 | if day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().max_day { |
| 267 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 268 | "day={day} is out of range for year={year} \ |
| 269 | and month={month}, must be in range 1..={max_day}", |
| 270 | )); |
| 271 | } |
| 272 | } |
| 273 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. }) |
| 274 | } |
| 275 | |
| 276 | /// Returns the date corresponding to the day of the given year. The day |
| 277 | /// of the year should be a value in `1..=366`, with `366` only being valid |
| 278 | /// if `year` is a leap year. |
| 279 | /// |
| 280 | /// This assumes that `year` is valid, but returns an error if `day` is |
| 281 | /// not in the range `1..=366`. |
| 282 | #[inline] |
| 283 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn from_day_of_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]from_day_of_year().( |
| 284 | year: i16, |
| 285 | day: i16, |
| 286 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 287 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().day && day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().366) { |
| 288 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 289 | "day-of-year={day} is out of range for year={year}, \ |
| 290 | must be in range 1..={max_day}", |
| 291 | max_day = days_in_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_year().(year), |
| 292 | )); |
| 293 | } |
| 294 | let start = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }.to_epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]to_epoch_day().(); |
| 295 | let end = start |
| 296 | .checked_addrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]checked_add().(i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(day) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().1) |
| 297 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| { |
| 298 | errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 299 | "failed to find date for \ |
| 300 | year={year} and day-of-year={day}: \ |
| 301 | adding `{day}` to `{start}` overflows \ |
| 302 | Jiff's range", |
| 303 | start = start.epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day., |
| 304 | ) |
| 305 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 306 | .to_daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]to_date().(); |
| 307 | // If we overflowed into the next year, then `day` is too big. |
| 308 | if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne().end.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year. { |
| 309 | // Can only happen given day=366 and this is a leap year. |
| 310 | debug_assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_eq!!(day, 366); |
| 311 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(year)); |
| 312 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 313 | "day-of-year={day} is out of range for year={year}, \ |
| 314 | must be in range 1..={max_day}", |
| 315 | max_day = days_in_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_year().(year), |
| 316 | )); |
| 317 | } |
| 318 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(end) |
| 319 | } |
| 320 | |
| 321 | /// Returns the date corresponding to the day of the given year. The day |
| 322 | /// of the year should be a value in `1..=365`, with February 29 being |
| 323 | /// completely ignored. That is, it is guaranteed that February 29 will |
| 324 | /// never be returned by this function. It is impossible. |
| 325 | /// |
| 326 | /// This assumes that `year` is valid, but returns an error if `day` is |
| 327 | /// not in the range `1..=365`. |
| 328 | #[inline] |
| 329 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn from_day_of_year_no_leaprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]from_day_of_year_no_leap().( |
| 330 | year: i16, |
| 331 | mut day: i16, |
| 332 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 333 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().day && day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().365) { |
| 334 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 335 | "day-of-year={day} is out of range for year={year}, \ |
| 336 | must be in range 1..=365", |
| 337 | )); |
| 338 | } |
| 339 | if day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().60 && is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(year) { |
| 340 | day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().1; |
| 341 | } |
| 342 | // The boundary check above guarantees this always succeeds. |
| 343 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#::from_day_of_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]from_day_of_year().(year, day).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 344 | } |
| 345 | |
| 346 | /// Converts a Gregorian date to days since the Unix epoch. |
| 347 | /// |
| 348 | /// This is Neri-Schneider. There's no branching or divisions. |
| 349 | /// |
| 350 | /// Ref: https://github.com/cassioneri/eaf/blob/684d3cc32d14eee371d0abe4f683d6d6a49ed5c1/algorithms/neri_schneider.hpp#L83 |
| 351 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 352 | #[allow(non_upper_case_globals, non_snake_case)] // to mimic source |
| 353 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]to_epoch_day().(&self) -> IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { |
| 354 | const srust-analyzer cargo jiff-static 0.2.16 shared/util/itime/s.: u32 = 82; |
| 355 | const Krust-analyzer cargo jiff-static 0.2.16 shared/util/itime/K.: u32 = 719468 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().146097 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().srust-analyzer cargo jiff-static 0.2.16 shared/util/itime/s.; |
| 356 | const Lrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/L.: u32 = 400 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().srust-analyzer cargo jiff-static 0.2.16 shared/util/itime/s.; |
| 357 | |
| 358 | let year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year. as u32; |
| 359 | let month = self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month. as u32; |
| 360 | let day = self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. as u32; |
| 361 | |
| 362 | let J = month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]le().2; |
| 363 | let Y = year.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(Lrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/L.).wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_sub().(J as u32); |
| 364 | let M = if J { month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().12 } else { month }; |
| 365 | let D = day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().1; |
| 366 | let C = Y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().100; |
| 367 | |
| 368 | let y_star = 1461 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().Y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().C rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().C rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().4; |
| 369 | let m_star = (979 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().M rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Sub<Self>`]sub().2919) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().32; |
| 370 | let N = y_star rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().m_star rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().D; |
| 371 | |
| 372 | let N_U = N.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_sub().(Krust-analyzer cargo jiff-static 0.2.16 shared/util/itime/K.); |
| 373 | let epoch_day = N_U as i32; |
| 374 | IEpochDayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay# { epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IEpochDay#epoch_day. } |
| 375 | } |
| 376 | |
| 377 | /// Returns the day of the week for this date. |
| 378 | #[inline] |
| 379 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]weekday().(&self) -> IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 380 | self.to_epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]to_epoch_day().().weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]weekday().() |
| 381 | } |
| 382 | |
| 383 | /// Returns the `nth` weekday of the month represented by this date. |
| 384 | /// |
| 385 | /// `nth` must be non-zero and otherwise in the range `-5..=5`. If it |
| 386 | /// isn't, an error is returned. |
| 387 | /// |
| 388 | /// This also returns an error if `abs(nth)==5` and there is no "5th" |
| 389 | /// weekday of this month. |
| 390 | #[inline] |
| 391 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn nth_weekday_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]nth_weekday_of_month().( |
| 392 | &self, |
| 393 | nth: i8, |
| 394 | weekday: IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#, |
| 395 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 396 | if nth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().0 || !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().5 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le().nth && nth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]le().5) { |
| 397 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 398 | "got nth weekday of `{nth}`, but \ |
| 399 | must be non-zero and in range `-5..=5`", |
| 400 | )); |
| 401 | } |
| 402 | if nth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]gt().0 { |
| 403 | let first_weekday = self.first_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]first_of_month().().weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]weekday().(); |
| 404 | let diff = weekday.sincerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]since().(first_weekday); |
| 405 | let day = diff rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().(nth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Mul<Self>`]mul().7; |
| 406 | IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#::try_newrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]try_new().(self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., day) |
| 407 | } else { |
| 408 | let last = self.last_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]last_of_month().(); |
| 409 | let last_weekday = last.weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]weekday().(); |
| 410 | let diff = last_weekday.sincerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]since().(weekday); |
| 411 | let day = last.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().diff rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().(nth.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i8]abs().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Mul<Self>`]mul().7; |
| 412 | // Our math can go below 1 when nth is -5 and there is no "5th from |
| 413 | // last" weekday in this month. Since this is outside the bounds |
| 414 | // of `Day`, we can't let this boundary condition escape. So we |
| 415 | // check it here. |
| 416 | if day rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]lt().1 { |
| 417 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 418 | "day={day} is out of range for year={year} \ |
| 419 | and month={month}, must be in range 1..={max_day}", |
| 420 | year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., |
| 421 | month = self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., |
| 422 | max_day = days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.), |
| 423 | )); |
| 424 | } |
| 425 | IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#::try_newrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]try_new().(self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., day) |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | /// Returns the day before this date. |
| 430 | #[inline] |
| 431 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]yesterday().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 432 | if self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().1 { |
| 433 | if self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().1 { |
| 434 | let year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1; |
| 435 | if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10000 { |
| 436 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 437 | "returning yesterday for -9999-01-01 is not \ |
| 438 | possible because it is less than Jiff's supported |
| 439 | minimum date", |
| 440 | )); |
| 441 | } |
| 442 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 12, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }); |
| 443 | } |
| 444 | let month = self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1; |
| 445 | let day = days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., month); |
| 446 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day., ..self }); |
| 447 | } |
| 448 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1, ..self }) |
| 449 | } |
| 450 | |
| 451 | /// Returns the day after this date. |
| 452 | #[inline] |
| 453 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]tomorrow().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 454 | if self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]ge().28 && self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.) { |
| 455 | if self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().12 { |
| 456 | let year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1; |
| 457 | if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().10000 { |
| 458 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 459 | "returning tomorrow for 9999-12-31 is not \ |
| 460 | possible because it is greater than Jiff's supported |
| 461 | maximum date", |
| 462 | )); |
| 463 | } |
| 464 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }); |
| 465 | } |
| 466 | let month = self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1; |
| 467 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1, ..self }); |
| 468 | } |
| 469 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1, ..self }) |
| 470 | } |
| 471 | |
| 472 | /// Returns the year one year before this date. |
| 473 | #[inline] |
| 474 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn prev_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]prev_year().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i16, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 475 | let year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1; |
| 476 | if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().10_000 { |
| 477 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 478 | "returning previous year for {year:04}-{month:02}-{day:02} is \ |
| 479 | not possible because it is less than Jiff's supported \ |
| 480 | minimum date", |
| 481 | year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., |
| 482 | month = self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., |
| 483 | day = self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day., |
| 484 | )); |
| 485 | } |
| 486 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(year) |
| 487 | } |
| 488 | |
| 489 | /// Returns the year one year from this date. |
| 490 | #[inline] |
| 491 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn next_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]next_year().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i16, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 492 | let year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1; |
| 493 | if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().10_000 { |
| 494 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(errrust-analyzer cargo jiff-static 0.2.16 shared/util/error/err!!( |
| 495 | "returning next year for {year:04}-{month:02}-{day:02} is \ |
| 496 | not possible because it is greater than Jiff's supported \ |
| 497 | maximum date", |
| 498 | year = self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., |
| 499 | month = self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., |
| 500 | day = self.dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day., |
| 501 | )); |
| 502 | } |
| 503 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(year) |
| 504 | } |
| 505 | |
| 506 | /// Add the number of days to this date. |
| 507 | #[inline] |
| 508 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn checked_add_daysrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]checked_add_days().( |
| 509 | &self, |
| 510 | amount: i32, |
| 511 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#, Errorrust-analyzer cargo jiff-static 0.2.16 shared/util/error/Error#> { |
| 512 | match amount { |
| 513 | 0 => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self), |
| 514 | -1 => self.yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]yesterday().(), |
| 515 | 1 => self.tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]tomorrow().(), |
| 516 | n => self.to_epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]to_epoch_day().().checked_addrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]checked_add().(n).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|d| d.to_daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]to_date().()), |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | #[inline] |
| 521 | fn first_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]first_of_month().(&self) -> IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { |
| 522 | IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1, ..*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self } |
| 523 | } |
| 524 | |
| 525 | #[inline] |
| 526 | fn last_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]last_of_month().(&self) -> IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { |
| 527 | IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(self.yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., self.monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.), ..*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self } |
| 528 | } |
| 529 | |
| 530 | #[cfg(test)] |
| 531 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) fn atrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]at().( |
| 532 | &self, |
| 533 | hour: i8, |
| 534 | minute: i8, |
| 535 | second: i8, |
| 536 | subsec_nanosecond: i32, |
| 537 | ) -> IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { |
| 538 | let time = ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour., minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute., secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second., subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond. }; |
| 539 | IDateTimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime# { daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#date.: *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDateTime#time. } |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | /// Represents a clock time. |
| 544 | /// |
| 545 | /// This uses units of hours, minutes, seconds and fractional seconds (to |
| 546 | /// nanosecond precision). |
| 547 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 548 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { |
| 549 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour.: i8, |
| 550 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute.: i8, |
| 551 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second.: i8, |
| 552 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond.: i32, |
| 553 | } |
| 554 | |
| 555 | impl ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { |
| 556 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const ZEROrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]ZERO.: ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# = |
| 557 | ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour.: 0, minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute.: 0, secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second.: 0, subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond.: 0 }; |
| 558 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const MINrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]MIN.: ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# = |
| 559 | ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour.: 0, minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute.: 0, secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second.: 0, subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond.: 0 }; |
| 560 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const MAXrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]MAX.: ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# = ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { |
| 561 | hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour.: 23, |
| 562 | minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute.: 59, |
| 563 | secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second.: 59, |
| 564 | subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond.: 999_999_999, |
| 565 | }; |
| 566 | |
| 567 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 568 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]to_second().(&self) -> ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { |
| 569 | let mut second: i32 = 0; |
| 570 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().(self.hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour. as i32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().3600; |
| 571 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().(self.minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute. as i32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().60; |
| 572 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().self.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second. as i32; |
| 573 | ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second. } |
| 574 | } |
| 575 | |
| 576 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 577 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]to_nanosecond().(&self) -> ITimeNanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond# { |
| 578 | let mut nanosecond: i64 = 0; |
| 579 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().(self.hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour. as i64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().3_600_000_000_000; |
| 580 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().(self.minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute. as i64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().60_000_000_000; |
| 581 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().(self.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second. as i64) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().1_000_000_000; |
| 582 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`AddAssign<Self>`]add_assign().self.subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond. as i64; |
| 583 | ITimeNanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond# { nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond#nanosecond. } |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | /// Represents a single point in the day, to second precision. |
| 588 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 589 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { |
| 590 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second.: i32, |
| 591 | } |
| 592 | |
| 593 | impl ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { |
| 594 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 595 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimeSecond]to_time().(&self) -> ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { |
| 596 | let mut second = self.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second.; |
| 597 | let mut time = ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#::ZEROrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]ZERO.; |
| 598 | if second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 { |
| 599 | time.hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour. = (second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().3600) as i8; |
| 600 | second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`RemAssign<Self>`]rem_assign().%=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`RemAssign<Self>`]rem_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`RemAssign<Self>`]rem_assign().3600; |
| 601 | if second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 { |
| 602 | time.minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute. = (second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Div<Self>`]div().60) as i8; |
| 603 | time.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second. = (second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Rem<Self>`]rem().60) as i8; |
| 604 | } |
| 605 | } |
| 606 | time |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | /// Represents a single point in the day, to nanosecond precision. |
| 611 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 612 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct ITimeNanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond# { |
| 613 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond#nanosecond.: i64, |
| 614 | } |
| 615 | |
| 616 | impl ITimeNanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond# { |
| 617 | #[cfg_attr(feature = "perf-inline", inline(always))] |
| 618 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimeNanosecond]to_time().(&self) -> ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime# { |
| 619 | let mut nanosecond = self.nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond#nanosecond.; |
| 620 | let mut time = ITimerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#::ZEROrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]ZERO.; |
| 621 | if nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 { |
| 622 | time.hourrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#hour. = (nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().3_600_000_000_000) as i8; |
| 623 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`RemAssign<Self>`]rem_assign().%=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`RemAssign<Self>`]rem_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`RemAssign<Self>`]rem_assign().3_600_000_000_000; |
| 624 | if nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 { |
| 625 | time.minuterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#minute. = (nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().60_000_000_000) as i8; |
| 626 | nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`RemAssign<Self>`]rem_assign().%=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`RemAssign<Self>`]rem_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`RemAssign<Self>`]rem_assign().60_000_000_000; |
| 627 | if nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i64][`PartialEq<Self>`]ne().0 { |
| 628 | time.secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#second. = (nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Div<Self>`]div().1_000_000_000) as i8; |
| 629 | time.subsec_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITime#subsec_nanosecond. = |
| 630 | (nanosecond rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Rem<Self>`]rem().1_000_000_000) as i32; |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | time |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | /// Represents a weekday. |
| 639 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 640 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) struct IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 641 | /// Range is `1..=6` with `1=Monday`. |
| 642 | offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#offset.: i8, |
| 643 | } |
| 644 | |
| 645 | impl IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 646 | /// Creates a weekday assuming the week starts on Monday and Monday is at |
| 647 | /// offset `0`. |
| 648 | #[inline] |
| 649 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn from_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_zero_offset().(offset: i8) -> IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 650 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(0 <= offset && offset <= 6); |
| 651 | IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_monday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_one_offset().(offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1) |
| 652 | } |
| 653 | |
| 654 | /// Creates a weekday assuming the week starts on Monday and Monday is at |
| 655 | /// offset `1`. |
| 656 | #[inline] |
| 657 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn from_monday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_one_offset().(offset: i8) -> IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 658 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(1 <= offset && offset <= 7); |
| 659 | IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#offset. } |
| 660 | } |
| 661 | |
| 662 | /// Creates a weekday assuming the week starts on Sunday and Sunday is at |
| 663 | /// offset `0`. |
| 664 | #[inline] |
| 665 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(offset: i8) -> IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 666 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(0 <= offset && offset <= 6); |
| 667 | IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_zero_offset().((offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1).rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i8]rem_euclid().(7)) |
| 668 | } |
| 669 | |
| 670 | /// Creates a weekday assuming the week starts on Sunday and Sunday is at |
| 671 | /// offset `1`. |
| 672 | #[cfg(test)] // currently dead code |
| 673 | #[inline] |
| 674 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn from_sunday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_one_offset().(offset: i8) -> IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday# { |
| 675 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(1 <= offset && offset <= 7); |
| 676 | IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1) |
| 677 | } |
| 678 | |
| 679 | /// Returns this weekday as an offset in the range `0..=6` where |
| 680 | /// `0=Monday`. |
| 681 | #[inline] |
| 682 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_zero_offset().(self) -> i8 { |
| 683 | self.to_monday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_one_offset().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().1 |
| 684 | } |
| 685 | |
| 686 | /// Returns this weekday as an offset in the range `1..=7` where |
| 687 | /// `1=Monday`. |
| 688 | #[inline] |
| 689 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_monday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_one_offset().(self) -> i8 { |
| 690 | self.offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#offset. |
| 691 | } |
| 692 | |
| 693 | /// Returns this weekday as an offset in the range `0..=6` where |
| 694 | /// `0=Sunday`. |
| 695 | #[cfg(test)] // currently dead code |
| 696 | #[inline] |
| 697 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_sunday_zero_offset().(self) -> i8 { |
| 698 | (self.to_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_zero_offset().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Rem<Self>`]rem().7 |
| 699 | } |
| 700 | |
| 701 | /// Returns this weekday as an offset in the range `1..=7` where |
| 702 | /// `1=Sunday`. |
| 703 | #[cfg(test)] // currently dead code |
| 704 | #[inline] |
| 705 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn to_sunday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_sunday_one_offset().(self) -> i8 { |
| 706 | self.to_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_sunday_zero_offset().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Add<Self>`]add().1 |
| 707 | } |
| 708 | |
| 709 | #[inline] |
| 710 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn sincerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]since().(self, other: IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#) -> i8 { |
| 711 | (self.to_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_zero_offset().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][`Sub<Self>`]sub().other.to_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_zero_offset().()) |
| 712 | .rem_euclidrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i8]rem_euclid().(7) |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 717 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) enum IAmbiguousOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset# { |
| 718 | Unambiguousrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Unambiguous# { offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Unambiguous#offset.: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# }, |
| 719 | Gaprust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Gap# { beforerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Gap#before.: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#, afterrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Gap#after.: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# }, |
| 720 | Foldrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Fold# { beforerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Fold#before.: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset#, afterrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IAmbiguousOffset#Fold#after.: IOffsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IOffset# }, |
| 721 | } |
| 722 | |
| 723 | /// Returns true if and only if the given year is a leap year. |
| 724 | /// |
| 725 | /// A leap year is a year with 366 days. Typical years have 365 days. |
| 726 | #[inline] |
| 727 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(year: i16) -> bool { |
| 728 | // From: https://github.com/BurntSushi/jiff/pull/23 |
| 729 | let d = if year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().25 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne().0 { 4 } else { 16 }; |
| 730 | (year rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Rem<Self>`]rem().d) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 |
| 731 | } |
| 732 | |
| 733 | /// Return the number of days in the given year. |
| 734 | #[inline] |
| 735 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn days_in_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_year().(year: i16) -> i16 { |
| 736 | if is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(year) { |
| 737 | 366 |
| 738 | } else { |
| 739 | 365 |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | /// Return the number of days in the given month. |
| 744 | #[inline] |
| 745 | pub(craterust-analyzer cargo jiff-static 0.2.16 crate/) const fn days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(year: i16, month: i8) -> i8 { |
| 746 | // From: https://github.com/BurntSushi/jiff/pull/23 |
| 747 | if month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialEq<Self>`]eq().2 { |
| 748 | if is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(year) { |
| 749 | 29 |
| 750 | } else { |
| 751 | 28 |
| 752 | } |
| 753 | } else { |
| 754 | 30 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`BitOr<Self>`]bitor().(month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`BitXor<Self>`]bitxor().month rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i8][`Shr<i32>`]shr().3) |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | #[cfg(test)] |
| 759 | mod testsrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/ { |
| 760 | use superrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/::*; |
| 761 | |
| 762 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 763 | fn roundtrip_epochday_daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/roundtrip_epochday_date().() { |
| 764 | for year in -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9999..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#9999 { |
| 765 | for month in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#12 { |
| 766 | for day in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(year, month) { |
| 767 | let date = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year., monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month., dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day. }; |
| 768 | let epoch_day = date.to_epoch_dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]to_epoch_day().(); |
| 769 | let date_roundtrip = epoch_day.to_daterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IEpochDay]to_date().(); |
| 770 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(date, date_roundtrip); |
| 771 | } |
| 772 | } |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 777 | fn roundtrip_second_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/roundtrip_second_time().() { |
| 778 | for second in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#86_399 { |
| 779 | let second = ITimeSecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond# { secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeSecond#second. }; |
| 780 | let time = second.to_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimeSecond]to_time().(); |
| 781 | let second_roundtrip = time.to_secondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]to_second().(); |
| 782 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(second, second_roundtrip); |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 787 | fn roundtrip_nanosecond_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/roundtrip_nanosecond_time().() { |
| 788 | for second in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#86_399 { |
| 789 | for nanosecond in |
| 790 | [0, 250_000_000, 500_000_000, 750_000_000, 900_000_000] |
| 791 | { |
| 792 | let nanosecond = ITimeNanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond# { |
| 793 | nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/ITimeNanosecond#nanosecond.: (second rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Mul<Self>`]mul().1_000_000_000 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][`Add<Self>`]add().nanosecond), |
| 794 | }; |
| 795 | let time = nanosecond.to_timerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITimeNanosecond]to_time().(); |
| 796 | let nanosecond_roundtrip = time.to_nanosecondrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[ITime]to_nanosecond().(); |
| 797 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nanosecond, nanosecond_roundtrip); |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 803 | fn nth_weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/nth_weekday().() { |
| 804 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2017, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 805 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(5); |
| 806 | let d2 = d1.nth_weekday_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]nth_weekday_of_month().(2, wday).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 807 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2017, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 10 }); |
| 808 | |
| 809 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2024, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 810 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(4); |
| 811 | let d2 = d1.nth_weekday_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]nth_weekday_of_month().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().1, wday).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 812 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2024, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 28 }); |
| 813 | |
| 814 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2024, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 25 }; |
| 815 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(1); |
| 816 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(d1.nth_weekday_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]nth_weekday_of_month().(5, wday).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 817 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(d1.nth_weekday_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]nth_weekday_of_month().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().5, wday).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 818 | |
| 819 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 1998, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 820 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(6); |
| 821 | let d2 = d1.nth_weekday_of_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]nth_weekday_of_month().(5, wday).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 822 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 1998, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }); |
| 823 | } |
| 824 | |
| 825 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 826 | fn weekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/weekday().() { |
| 827 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(0); |
| 828 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wday.to_monday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_one_offset().(), 7); |
| 829 | |
| 830 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_monday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_one_offset().(7); |
| 831 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wday.to_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_sunday_zero_offset().(), 0); |
| 832 | |
| 833 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_one_offset().(1); |
| 834 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wday.to_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_monday_zero_offset().(), 6); |
| 835 | |
| 836 | let wday = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_monday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_monday_zero_offset().(6); |
| 837 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wday.to_sunday_one_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]to_sunday_one_offset().(), 1); |
| 838 | } |
| 839 | |
| 840 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 841 | fn weekday_sincerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/weekday_since().() { |
| 842 | let wday1 = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(0); |
| 843 | let wday2 = IWeekdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IWeekday#::from_sunday_zero_offsetrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]from_sunday_zero_offset().(6); |
| 844 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wday2.sincerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]since().(wday1), 6); |
| 845 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(wday1.sincerust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IWeekday]since().(wday2), 1); |
| 846 | } |
| 847 | |
| 848 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 849 | fn leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/leap_year().() { |
| 850 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(1900)); |
| 851 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(2000)); |
| 852 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(2001)); |
| 853 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(2002)); |
| 854 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(2003)); |
| 855 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(is_leap_yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/is_leap_year().(2004)); |
| 856 | } |
| 857 | |
| 858 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 859 | fn number_of_days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/number_of_days_in_month().() { |
| 860 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 1), 31); |
| 861 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 2), 29); |
| 862 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 3), 31); |
| 863 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 4), 30); |
| 864 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 5), 31); |
| 865 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 6), 30); |
| 866 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 7), 31); |
| 867 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 8), 31); |
| 868 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 9), 30); |
| 869 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 10), 31); |
| 870 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 11), 30); |
| 871 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2024, 12), 31); |
| 872 | |
| 873 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 1), 31); |
| 874 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 2), 28); |
| 875 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 3), 31); |
| 876 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 4), 30); |
| 877 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 5), 31); |
| 878 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 6), 30); |
| 879 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 7), 31); |
| 880 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 8), 31); |
| 881 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 9), 30); |
| 882 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 10), 31); |
| 883 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 11), 30); |
| 884 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2025, 12), 31); |
| 885 | |
| 886 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(1900, 2), 28); |
| 887 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(days_in_monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/days_in_month().(2000, 2), 29); |
| 888 | } |
| 889 | |
| 890 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 891 | fn yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/yesterday().() { |
| 892 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 4, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 7 }; |
| 893 | let d2 = d1.yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]yesterday().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 894 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 4, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 6 }); |
| 895 | |
| 896 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 4, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 897 | let d2 = d1.yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]yesterday().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 898 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }); |
| 899 | |
| 900 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 901 | let d2 = d1.yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]yesterday().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 902 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2024, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 12, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }); |
| 903 | |
| 904 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().9999, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }; |
| 905 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d1.yesterdayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]yesterday().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 906 | } |
| 907 | |
| 908 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 909 | fn tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/tests/tomorrow().() { |
| 910 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 4, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 7 }; |
| 911 | let d2 = d1.tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]tomorrow().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 912 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 4, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 8 }); |
| 913 | |
| 914 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 3, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }; |
| 915 | let d2 = d1.tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]tomorrow().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 916 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 4, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }); |
| 917 | |
| 918 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2025, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 12, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }; |
| 919 | let d2 = d1.tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]tomorrow().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 920 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d2, IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 2026, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 1, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 1 }); |
| 921 | |
| 922 | let d1 = IDaterust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate# { yearrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#year.: 9999, monthrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#month.: 12, dayrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/IDate#day.: 31 }; |
| 923 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(d1.tomorrowrust-analyzer cargo jiff-static 0.2.16 shared/util/itime/impl#[IDate]tomorrow().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 924 | } |
| 925 | } |