/// Find the local time type associated to the time zone at the specified Unix time in seconds
Find the local time type associated to the time zone at the specified Unix time in seconds
Find the local time type associated to the time zone at the specified Unix time in seconds
pub(crate) fn find_local_time_type(&self, unix_time: i64) -> Result<&'a LocalTimeType, Error> {
        let extra_rule = match self.transitions.last() {
            None => match self.extra_rule {
                Some(extra_rule) => extra_rule,
                None => return Ok(&self.local_time_types[0]),
            },
            Some(last_transition) => {
                let unix_leap_time = match self.unix_time_to_unix_leap_time(unix_time) {
                    Ok(unix_leap_time) => unix_leap_time,
                    Err(Error::OutOfRange(error)) => return Err(Error::FindLocalTimeType(error)),
                    Err(err) => return Err(err),
                };
                if unix_leap_time >= last_transition.unix_leap_time {
                    match self.extra_rule {
                        Some(extra_rule) => extra_rule,
                        None => {
                            return Err(Error::FindLocalTimeType(
                                "no local time type is available for the specified timestamp",
                            ))
                        }
                    }
                } else {
                    let index = match self
                        .transitions
                        .binary_search_by_key(&unix_leap_time, Transition::unix_leap_time)
                    {
                        Ok(x) => x + 1,
                        Err(x) => x,
                    };
                    let local_time_type_index = if index > 0 {
                        self.transitions[index - 1].local_time_type_index
                    } else {
                        0
                    };
                    return Ok(&self.local_time_types[local_time_type_index]);
                }
            }
        };
        match extra_rule.find_local_time_type(unix_time) {
            Ok(local_time_type) => Ok(local_time_type),
            Err(Error::OutOfRange(error)) => Err(Error::FindLocalTimeType(error)),
            err => err,
        }
    }
pub ( crate ) fn find_local_time_type ( & self , unix_time : i64 ) -> Result < & ' a LocalTimeType , Error > { let extra_rule = match self . transitions . last ( ) { None => match self . extra_rule { Some ( extra_rule ) => extra_rule , None => return Ok ( & self . local_time_types [ 0 ] ) , } , Some ( last_transition ) => { let unix_leap_time = match self . unix_time_to_unix_leap_time ( unix_time ) { Ok ( unix_leap_time ) => unix_leap_time , Err ( Error :: OutOfRange ( error ) ) => return Err ( Error :: FindLocalTimeType ( error ) ) , Err ( err ) => return Err ( err ) , } ; if unix_leap_time >= last_transition . unix_leap_time { match self . extra_rule { Some ( extra_rule ) => extra_rule , None => { return Err ( Error :: FindLocalTimeType ( " " , ) ) } } } else { let index = match self . transitions . binary_search_by_key ( & unix_leap_time , Transition :: unix_leap_time ) { Ok ( x ) => x + 1 , Err ( x ) => x , } ; let local_time_type_index = if index > 0 { self . transitions [ index - 1 ] . local_time_type_index } else { 0 } ; return Ok ( & self . local_time_types [ local_time_type_index ] ) ; } } } ; match extra_rule . find_local_time_type ( unix_time ) { Ok ( local_time_type ) => Ok ( local_time_type ) , Err ( Error :: OutOfRange ( error ) ) => Err ( Error :: FindLocalTimeType ( error ) ) , err => err , } }
Find the local time type associated to the time zone at the specified Unix time in seconds
Find the local time type associated to the time zone at the specified Unix time in seconds
&self
unix_time
i64