| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/; |
| 2 | |
| 3 | use craterust-analyzer cargo rrule 0.14.0 crate/::corerust-analyzer cargo rrule 0.14.0 core/::{duration_from_midnightrust-analyzer cargo rrule 0.14.0 core/datetime/duration_from_midnight()., Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#}; |
| 4 | use chronorust-analyzer cargo chrono 0.4.40 crate/::{NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#, NaiveTimerust-analyzer cargo chrono 0.4.40 naive/time/NaiveTime#, Utcrust-analyzer cargo chrono 0.4.40 offset/utc/Utc#}; |
| 5 | |
| 6 | const DAY_SECSrust-analyzer cargo rrule 0.14.0 iter/utils/DAY_SECS.: i64 = 24 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 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; |
| 7 | |
| 8 | /// Converts number of days since unix epoch to a (naive) date. |
| 9 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn date_from_ordinalrust-analyzer cargo rrule 0.14.0 iter/utils/date_from_ordinal().(ordinal: i64) -> NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate# { |
| 10 | chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#::<Utcrust-analyzer cargo chrono 0.4.40 offset/utc/Utc#>::from_timestamprust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Utc>`]from_timestamp().(ordinal 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().DAY_SECSrust-analyzer cargo rrule 0.14.0 iter/utils/DAY_SECS., 0) |
| 11 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 12 | .date_naiverust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]date_naive().() |
| 13 | } |
| 14 | |
| 15 | /// Returns number of days since unix epoch (rounded down) |
| 16 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn days_since_unix_epochrust-analyzer cargo rrule 0.14.0 iter/utils/days_since_unix_epoch().(date: &chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Utcrust-analyzer cargo chrono 0.4.40 offset/utc/Utc#>) -> i64 { |
| 17 | date.timestamprust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]timestamp().() 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().DAY_SECSrust-analyzer cargo rrule 0.14.0 iter/utils/DAY_SECS. |
| 18 | } |
| 19 | |
| 20 | /// Returns true if given year is a leap year |
| 21 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn is_leap_yearrust-analyzer cargo rrule 0.14.0 iter/utils/is_leap_year().(year: i32) -> bool { |
| 22 | // Every 4 years, and every 100 years, |
| 23 | // but not if dividable by 400. |
| 24 | year.trailing_zerosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]trailing_zeros().() 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().2 && (year 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().25 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 || year.trailing_zerosrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]trailing_zeros().() 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().4) |
| 25 | } |
| 26 | |
| 27 | /// Returns number of days in year, |
| 28 | /// So 365 or 366 depending on the year |
| 29 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn get_year_lenrust-analyzer cargo rrule 0.14.0 iter/utils/get_year_len().(year: i32) -> u16 { |
| 30 | if is_leap_yearrust-analyzer cargo rrule 0.14.0 iter/utils/is_leap_year().(year) { |
| 31 | 366 |
| 32 | } else { |
| 33 | 365 |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) trait DifferentSignsrust-analyzer cargo rrule 0.14.0 iter/utils/DifferentSigns# { |
| 38 | fn different_signrust-analyzer cargo rrule 0.14.0 iter/utils/DifferentSigns#different_sign().(a: Self, b: Self) -> bool; |
| 39 | } |
| 40 | |
| 41 | macro_rules! impl_different_signsrust-analyzer cargo rrule 0.14.0 iter/utils/impl_different_signs! { |
| 42 | ($($ty:ty),*) => { |
| 43 | $( |
| 44 | impl DifferentSigns for $ty { |
| 45 | fn different_sign(a: Self, b: Self) -> bool { |
| 46 | a > 0 && b < 0 || a < 0 && b > 0 |
| 47 | } |
| 48 | })* |
| 49 | }; |
| 50 | (@unsigned, $($ty:ty),*) => { |
| 51 | $( |
| 52 | impl DifferentSigns for $ty { |
| 53 | fn different_sign(_: Self, _: Self) -> bool { |
| 54 | false |
| 55 | } |
| 56 | })* |
| 57 | }; |
| 58 | } |
| 59 | impl_different_signsrust-analyzer cargo rrule 0.14.0 iter/utils/impl_different_signs!!(isize, i32, i16); |
| 60 | impl_different_signsrust-analyzer cargo rrule 0.14.0 iter/utils/impl_different_signs!!(@unsigned, usize, u32, u16, u8); |
| 61 | |
| 62 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().<T>(a: T, b: T) -> T |
| 63 | where |
| 64 | T: DifferentSignsrust-analyzer cargo rrule 0.14.0 iter/utils/DifferentSigns# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Remrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Rem#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Rem#Output# = T> + opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#<Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#Output# = T>, |
| 65 | { |
| 66 | let r = a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Rem#rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Rem#rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Rem#rem().b; |
| 67 | // If r and b differ in sign, add b to wrap the result to the correct sign. |
| 68 | if T::different_signrust-analyzer cargo rrule 0.14.0 iter/utils/DifferentSigns#different_sign().(r, b) { |
| 69 | r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().b |
| 70 | } else { |
| 71 | r |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | pub(craterust-analyzer cargo rrule 0.14.0 crate/) fn add_time_to_daterust-analyzer cargo rrule 0.14.0 iter/utils/add_time_to_date().( |
| 76 | tz: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#, |
| 77 | date: NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#, |
| 78 | time: NaiveTimerust-analyzer cargo chrono 0.4.40 naive/time/NaiveTime#, |
| 79 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>> { |
| 80 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dt) = date.and_timerust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]and_time().(time).and_local_timezonerust-analyzer cargo chrono 0.4.40 naive/datetime/impl#[NaiveDateTime]and_local_timezone().(tz).singlerust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]single().() { |
| 81 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dt); |
| 82 | } |
| 83 | // If the day is a daylight saving time, the above code might not work, and we |
| 84 | // can try to get a valid datetime by adding the `time` as a duration instead. |
| 85 | let dt = date.and_hms_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]and_hms_opt().(0, 0, 0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..and_local_timezonerust-analyzer cargo chrono 0.4.40 naive/datetime/impl#[NaiveDateTime]and_local_timezone().(tz).singlerust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]single().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 86 | let day_duration = duration_from_midnightrust-analyzer cargo rrule 0.14.0 core/datetime/duration_from_midnight().(time); |
| 87 | dt.checked_add_signedrust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`]checked_add_signed().(day_duration) |
| 88 | } |
| 89 | |
| 90 | #[cfg(test)] |
| 91 | mod testrust-analyzer cargo rrule 0.14.0 iter/utils/test/ { |
| 92 | |
| 93 | use chronorust-analyzer cargo chrono 0.4.40 crate/::{Durationrust-analyzer cargo chrono 0.4.40 Duration#, TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#}; |
| 94 | |
| 95 | use superrust-analyzer cargo rrule 0.14.0 iter/utils/::*; |
| 96 | |
| 97 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 98 | fn naive_date_from_ordinalrust-analyzer cargo rrule 0.14.0 iter/utils/test/naive_date_from_ordinal().() { |
| 99 | let tests = [ |
| 100 | (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().1, NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(1969, 12, 31).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 101 | (0, NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(1970, 1, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 102 | (1, NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(1970, 1, 2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 103 | (10, NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(1970, 1, 11).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 104 | (365, NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(1971, 1, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 105 | (19877, NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(2024, 6, 3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 106 | ]; |
| 107 | |
| 108 | for (days, expected) in tests { |
| 109 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(date_from_ordinalrust-analyzer cargo rrule 0.14.0 iter/utils/date_from_ordinal().(days), expected, "seconds: {}", days); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 114 | fn python_modrust-analyzer cargo rrule 0.14.0 iter/utils/test/python_mod().() { |
| 115 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().3), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1); |
| 116 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().2, 3), 1); |
| 117 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().2, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().3), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().2); |
| 118 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().3, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().3), 0); |
| 119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(0, 3), 0); |
| 120 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(1, 3), 1); |
| 121 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(2, 3), 2); |
| 122 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(3, 3), 0); |
| 123 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(4, 3), 1); |
| 124 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(6, 3), 0); |
| 125 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().6, 3), 0); |
| 126 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().6, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().3), 0); |
| 127 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pymodrust-analyzer cargo rrule 0.14.0 iter/utils/pymod().(6, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().3), 0); |
| 128 | } |
| 129 | |
| 130 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 131 | fn leap_yearrust-analyzer cargo rrule 0.14.0 iter/utils/test/leap_year().() { |
| 132 | let tests = [ |
| 133 | (2015, false), |
| 134 | (2016, true), |
| 135 | (2017, false), |
| 136 | (2018, false), |
| 137 | (2019, false), |
| 138 | (2020, true), |
| 139 | (2021, false), |
| 140 | ]; |
| 141 | |
| 142 | for (year, expected_output) in tests { |
| 143 | let res = is_leap_yearrust-analyzer cargo rrule 0.14.0 iter/utils/is_leap_year().(year); |
| 144 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, expected_output); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 149 | fn year_lengthrust-analyzer cargo rrule 0.14.0 iter/utils/test/year_length().() { |
| 150 | let tests = [(2015, 365), (2016, 366)]; |
| 151 | |
| 152 | for (year, expected_output) in tests { |
| 153 | let res = get_year_lenrust-analyzer cargo rrule 0.14.0 iter/utils/get_year_len().(year); |
| 154 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, expected_output); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 159 | fn adds_time_to_daterust-analyzer cargo rrule 0.14.0 iter/utils/test/adds_time_to_date().() { |
| 160 | let tests = [ |
| 161 | ( |
| 162 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC., |
| 163 | NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(2017, 1, 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 164 | NaiveTimerust-analyzer cargo chrono 0.4.40 naive/time/NaiveTime#::from_hms_optrust-analyzer cargo chrono 0.4.40 naive/time/impl#[NaiveTime]from_hms_opt().(1, 15, 30).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 165 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2017, 1, 1, 1, 15, 30).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().()), |
| 166 | ), |
| 167 | ( |
| 168 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::America__Vancouverrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]America__Vancouver., |
| 169 | NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(2021, 3, 14).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 170 | NaiveTimerust-analyzer cargo chrono 0.4.40 naive/time/NaiveTime#::from_hms_optrust-analyzer cargo chrono 0.4.40 naive/time/impl#[NaiveTime]from_hms_opt().(2, 22, 10).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 171 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( |
| 172 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::America__Vancouverrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]America__Vancouver. |
| 173 | .with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(2021, 3, 14, 0, 0, 0) |
| 174 | .unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().() |
| 175 | +rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][`Add<TimeDelta>`]add(). rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][`Add<TimeDelta>`]add().Durationrust-analyzer cargo chrono 0.4.40 Duration#::hoursrust-analyzer cargo chrono 0.4.40 time_delta/impl#[TimeDelta]hours().(2) |
| 176 | +rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][`Add<TimeDelta>`]add(). rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][`Add<TimeDelta>`]add().Durationrust-analyzer cargo chrono 0.4.40 Duration#::minutesrust-analyzer cargo chrono 0.4.40 time_delta/impl#[TimeDelta]minutes().(22) |
| 177 | +rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][`Add<TimeDelta>`]add(). rust-analyzer cargo chrono 0.4.40 datetime/impl#[`DateTime<Tz>`][`Add<TimeDelta>`]add().Durationrust-analyzer cargo chrono 0.4.40 Duration#::secondsrust-analyzer cargo chrono 0.4.40 time_delta/impl#[TimeDelta]seconds().(10), |
| 178 | ), |
| 179 | ), |
| 180 | ( |
| 181 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::America__New_Yorkrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]America__New_York., |
| 182 | NaiveDaterust-analyzer cargo chrono 0.4.40 naive/date/NaiveDate#::from_ymd_optrust-analyzer cargo chrono 0.4.40 naive/date/impl#[NaiveDate]from_ymd_opt().(1997, 10, 26).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 183 | NaiveTimerust-analyzer cargo chrono 0.4.40 naive/time/NaiveTime#::from_hms_optrust-analyzer cargo chrono 0.4.40 naive/time/impl#[NaiveTime]from_hms_opt().(9, 0, 0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 184 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( |
| 185 | Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::America__New_Yorkrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]America__New_York. |
| 186 | .with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 10, 26, 9, 0, 0) |
| 187 | .unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(), |
| 188 | ), |
| 189 | ), |
| 190 | ]; |
| 191 | |
| 192 | for (tz, date, time, expected_output) in tests { |
| 193 | let res = add_time_to_daterust-analyzer cargo rrule 0.14.0 iter/utils/add_time_to_date().(tz, date, time); |
| 194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(res, expected_output); |
| 195 | } |
| 196 | } |
| 197 | } |