/// Construct a time zone from a POSIX TZ string, as described in [the POSIX documentation of the `TZ` environment variable](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html).
Construct a time zone from a POSIX TZ string, as described in [the POSIX documentation of the `TZ` environment variable].
Construct a time zone from a POSIX TZ string as described in [ the POSIX documentation of the ` TZ ` environment variable ] .
fn from_posix_tz(tz_string: &str) -> Result<Self, Error> {
        if tz_string.is_empty() {
            return Err(Error::InvalidTzString("empty TZ string"));
        }
        if tz_string == "localtime" {
            return Self::from_tz_data(&fs::read("/etc/localtime")?);
        }
        let mut chars = tz_string.chars();
        if chars.next() == Some(':') {
            return Self::from_file(&mut find_tz_file(chars.as_str())?);
        }
        if let Ok(mut file) = find_tz_file(tz_string) {
            return Self::from_file(&mut file);
        }
        // TZ string extensions are not allowed
        let tz_string = tz_string.trim_matches(|c: char| c.is_ascii_whitespace());
        let rule = TransitionRule::from_tz_string(tz_string.as_bytes(), false)?;
        Self::new(
            vec![],
            match rule {
                TransitionRule::Fixed(local_time_type) => vec![local_time_type],
                TransitionRule::Alternate(AlternateTime { std, dst, .. }) => vec![std, dst],
            },
            vec![],
            Some(rule),
        )
    }
fn from_posix_tz ( tz_string : & str ) -> Result < Self , Error > { if tz_string . is_empty ( ) { return Err ( Error :: InvalidTzString ( " " ) ) ; } if tz_string == " " { return Self :: from_tz_data ( & fs :: read ( " " ) ? ) ; } let mut chars = tz_string . chars ( ) ; if chars . next ( ) == Some ( ':' ) { return Self :: from_file ( & mut find_tz_file ( chars . as_str ( ) ) ? ) ; } if let Ok ( mut file ) = find_tz_file ( tz_string ) { return Self :: from_file ( & mut file ) ; } // TZ string extensions are not allowed let tz_string = tz_string . trim_matches ( | c : char | c . is_ascii_whitespace ( ) ) ; let rule = TransitionRule :: from_tz_string ( tz_string . as_bytes ( ) , false ) ? ; Self :: new ( vec ! [ ] , match rule { TransitionRule :: Fixed ( local_time_type ) => vec ! [ local_time_type ] , TransitionRule :: Alternate ( AlternateTime { std , dst , .. } ) => vec ! [ std dst ] , } , vec ! [ ] , Some ( rule ) , ) }
Construct a time zone from a POSIX TZ string, as described in [the POSIX documentation of the `TZ` environment variable](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html).
Construct a time zone from a POSIX TZ string as described in [ the POSIX documentation of the ` TZ ` environment variable ] ( https : // pubs . opengroup . org / onlinepubs / 9699919799 / basedefs / V1_chap08 . html ) .
tz_string
&str