fn find_local_time_type(&self, unix_time: i64) -> Result<&LocalTimeType, Error> {
        // Overflow is not possible
        let dst_start_time_in_utc = self.dst_start_time as i64 - self.std.ut_offset as i64;
        let dst_end_time_in_utc = self.dst_end_time as i64 - self.dst.ut_offset as i64;

        let current_year = match UtcDateTime::from_timespec(unix_time) {
            Ok(dt) => dt.year,
            Err(error) => return Err(error),
        };

        // Check if the current year is valid for the following computations
        if !(i32::min_value() + 2 <= current_year && current_year <= i32::max_value() - 2) {
            return Err(Error::OutOfRange("out of range date time"));
        }

        let current_year_dst_start_unix_time =
            self.dst_start.unix_time(current_year, dst_start_time_in_utc);
        let current_year_dst_end_unix_time =
            self.dst_end.unix_time(current_year, dst_end_time_in_utc);

        // Check DST start/end Unix times for previous/current/next years to support for transition day times outside of [0h, 24h] range
        let is_dst =
            match Ord::cmp(&current_year_dst_start_unix_time, &current_year_dst_end_unix_time) {
                Ordering::Less | Ordering::Equal => {
                    if unix_time < current_year_dst_start_unix_time {
                        let previous_year_dst_end_unix_time =
                            self.dst_end.unix_time(current_year - 1, dst_end_time_in_utc);
                        if unix_time < previous_year_dst_end_unix_time {
                            let previous_year_dst_start_unix_time =
                                self.dst_start.unix_time(current_year - 1, dst_start_time_in_utc);
                            previous_year_dst_start_unix_time <= unix_time
                        } else {
                            false
                        }
                    } else if unix_time < current_year_dst_end_unix_time {
                        true
                    } else {
                        let next_year_dst_start_unix_time =
                            self.dst_start.unix_time(current_year + 1, dst_start_time_in_utc);
                        if next_year_dst_start_unix_time <= unix_time {
                            let next_year_dst_end_unix_time =
                                self.dst_end.unix_time(current_year + 1, dst_end_time_in_utc);
                            unix_time < next_year_dst_end_unix_time
                        } else {
                            false
                        }
                    }
                }
                Ordering::Greater => {
                    if unix_time < current_year_dst_end_unix_time {
                        let previous_year_dst_start_unix_time =
                            self.dst_start.unix_time(current_year - 1, dst_start_time_in_utc);
                        if unix_time < previous_year_dst_start_unix_time {
                            let previous_year_dst_end_unix_time =
                                self.dst_end.unix_time(current_year - 1, dst_end_time_in_utc);
                            unix_time < previous_year_dst_end_unix_time
                        } else {
                            true
                        }
                    } else if unix_time < current_year_dst_start_unix_time {
                        false
                    } else {
                        let next_year_dst_end_unix_time =
                            self.dst_end.unix_time(current_year + 1, dst_end_time_in_utc);
                        if next_year_dst_end_unix_time <= unix_time {
                            let next_year_dst_start_unix_time =
                                self.dst_start.unix_time(current_year + 1, dst_start_time_in_utc);
                            next_year_dst_start_unix_time <= unix_time
                        } else {
                            true
                        }
                    }
                }
            };

        if is_dst {
            Ok(&self.dst)
        } else {
            Ok(&self.std)
        }
    }
/// Find the local time type associated to the alternate transition rule at the specified Unix time in seconds
Find the local time type associated to the alternate transition rule at the specified Unix time in seconds
Find the local time type associated to the alternate transition rule at the specified Unix time in seconds
fn find_local_time_type(&self, unix_time: i64) -> Result<&LocalTimeType, Error> {
        // Overflow is not possible
        let dst_start_time_in_utc = self.dst_start_time as i64 - self.std.ut_offset as i64;
        let dst_end_time_in_utc = self.dst_end_time as i64 - self.dst.ut_offset as i64;
        let current_year = match UtcDateTime::from_timespec(unix_time) {
            Ok(dt) => dt.year,
            Err(error) => return Err(error),
        };
        // Check if the current year is valid for the following computations
        if !(i32::min_value() + 2 <= current_year && current_year <= i32::max_value() - 2) {
            return Err(Error::OutOfRange("out of range date time"));
        }
        let current_year_dst_start_unix_time =
            self.dst_start.unix_time(current_year, dst_start_time_in_utc);
        let current_year_dst_end_unix_time =
            self.dst_end.unix_time(current_year, dst_end_time_in_utc);
        // Check DST start/end Unix times for previous/current/next years to support for transition day times outside of [0h, 24h] range
        let is_dst =
            match Ord::cmp(&current_year_dst_start_unix_time, &current_year_dst_end_unix_time) {
                Ordering::Less | Ordering::Equal => {
                    if unix_time < current_year_dst_start_unix_time {
                        let previous_year_dst_end_unix_time =
                            self.dst_end.unix_time(current_year - 1, dst_end_time_in_utc);
                        if unix_time < previous_year_dst_end_unix_time {
                            let previous_year_dst_start_unix_time =
                                self.dst_start.unix_time(current_year - 1, dst_start_time_in_utc);
                            previous_year_dst_start_unix_time <= unix_time
                        } else {
                            false
                        }
                    } else if unix_time < current_year_dst_end_unix_time {
                        true
                    } else {
                        let next_year_dst_start_unix_time =
                            self.dst_start.unix_time(current_year + 1, dst_start_time_in_utc);
                        if next_year_dst_start_unix_time <= unix_time {
                            let next_year_dst_end_unix_time =
                                self.dst_end.unix_time(current_year + 1, dst_end_time_in_utc);
                            unix_time < next_year_dst_end_unix_time
                        } else {
                            false
                        }
                    }
                }
                Ordering::Greater => {
                    if unix_time < current_year_dst_end_unix_time {
                        let previous_year_dst_start_unix_time =
                            self.dst_start.unix_time(current_year - 1, dst_start_time_in_utc);
                        if unix_time < previous_year_dst_start_unix_time {
                            let previous_year_dst_end_unix_time =
                                self.dst_end.unix_time(current_year - 1, dst_end_time_in_utc);
                            unix_time < previous_year_dst_end_unix_time
                        } else {
                            true
                        }
                    } else if unix_time < current_year_dst_start_unix_time {
                        false
                    } else {
                        let next_year_dst_end_unix_time =
                            self.dst_end.unix_time(current_year + 1, dst_end_time_in_utc);
                        if next_year_dst_end_unix_time <= unix_time {
                            let next_year_dst_start_unix_time =
                                self.dst_start.unix_time(current_year + 1, dst_start_time_in_utc);
                            next_year_dst_start_unix_time <= unix_time
                        } else {
                            true
                        }
                    }
                }
            };
        if is_dst {
            Ok(&self.dst)
        } else {
            Ok(&self.std)
        }
    }
fn find_local_time_type ( & self , unix_time : i64 ) -> Result < & LocalTimeType , Error > { // Overflow is not possible let dst_start_time_in_utc = self . dst_start_time as i64 - self . std . ut_offset as i64 ; let dst_end_time_in_utc = self . dst_end_time as i64 - self . dst . ut_offset as i64 ; let current_year = match UtcDateTime :: from_timespec ( unix_time ) { Ok ( dt ) => dt . year , Err ( error ) => return Err ( error ) , } ; // Check if the current year is valid for the following computations if ! ( i32 :: min_value ( ) + 2 <= current_year && current_year <= i32 :: max_value ( ) - 2 ) { return Err ( Error :: OutOfRange ( " " ) ) ; } let current_year_dst_start_unix_time = self . dst_start . unix_time ( current_year , dst_start_time_in_utc ) ; let current_year_dst_end_unix_time = self . dst_end . unix_time ( current_year , dst_end_time_in_utc ) ; // Check DST start/end Unix times for previous/current/next years to support for transition day times outside of [0h, 24h] range let is_dst = match Ord :: cmp ( & current_year_dst_start_unix_time , & current_year_dst_end_unix_time ) { Ordering :: Less | Ordering :: Equal => { if unix_time < current_year_dst_start_unix_time { let previous_year_dst_end_unix_time = self . dst_end . unix_time ( current_year - 1 , dst_end_time_in_utc ) ; if unix_time < previous_year_dst_end_unix_time { let previous_year_dst_start_unix_time = self . dst_start . unix_time ( current_year - 1 , dst_start_time_in_utc ) ; previous_year_dst_start_unix_time <= unix_time } else { false } } else if unix_time < current_year_dst_end_unix_time { true } else { let next_year_dst_start_unix_time = self . dst_start . unix_time ( current_year + 1 , dst_start_time_in_utc ) ; if next_year_dst_start_unix_time <= unix_time { let next_year_dst_end_unix_time = self . dst_end . unix_time ( current_year + 1 , dst_end_time_in_utc ) ; unix_time < next_year_dst_end_unix_time } else { false } } } Ordering :: Greater => { if unix_time < current_year_dst_end_unix_time { let previous_year_dst_start_unix_time = self . dst_start . unix_time ( current_year - 1 , dst_start_time_in_utc ) ; if unix_time < previous_year_dst_start_unix_time { let previous_year_dst_end_unix_time = self . dst_end . unix_time ( current_year - 1 , dst_end_time_in_utc ) ; unix_time < previous_year_dst_end_unix_time } else { true } } else if unix_time < current_year_dst_start_unix_time { false } else { let next_year_dst_end_unix_time = self . dst_end . unix_time ( current_year + 1 , dst_end_time_in_utc ) ; if next_year_dst_end_unix_time <= unix_time { let next_year_dst_start_unix_time = self . dst_start . unix_time ( current_year + 1 , dst_start_time_in_utc ) ; next_year_dst_start_unix_time <= unix_time } else { true } } } } ; if is_dst { Ok ( & self . dst ) } else { Ok ( & self . std ) } }
Find the local time type associated to the alternate transition rule at the specified Unix time in seconds
Find the local time type associated to the alternate transition rule at the specified Unix time in seconds
&self
unix_time
i64
&self
unix_time
i64