pub enum TzEnv {
Rule(TimeZone),
Implementation(TimeZoneId),
}Expand description
The result of parsing the POSIX TZ environment variable.
A TZ variable can either be a POSIX time zone string with an optional DST
transition rule, or it can begin with a : followed by an arbitrary set of
bytes that is implementation defined.
In practice, the content following a : is treated as an IANA time zone
name. Moreover, even if the TZ string doesn’t start with a : but
corresponds to a IANA time zone name, then it is interpreted as such.
However, this type only encapsulates the choices strictly provided by
POSIX: either a time zone string with an optional DST transition rule,
or an implementation defined string with a : prefix. If, for example,
TZ="America/New_York", then that case isn’t encapsulated by this type.
Callers needing that functionality will need to handle the error returned
by parsing this type and layer their own semantics on top. In general, any
valid IANA time zone identifier will be an invalid POSIX time zone string.
Variants§
Rule(TimeZone)
A valid POSIX time zone with an optional DST transition rule.
Implementation(TimeZoneId)
An implementation defined string. This occurs when the TZ value
starts with a :. The string stored here does not include the :.
Typically this is an IANA time zone identifier.
Implementations§
Source§impl TzEnv
impl TzEnv
Sourcepub fn parse<B: AsRef<[u8]>>(bytes: B) -> Result<TzEnv, ParseError>
pub fn parse<B: AsRef<[u8]>>(bytes: B) -> Result<TzEnv, ParseError>
Parse a POSIX TZ environment variable string from the given bytes.
Sourcepub fn parse_os_str<O: AsRef<OsStr>>(osstr: O) -> Result<TzEnv, ParseError>
pub fn parse_os_str<O: AsRef<OsStr>>(osstr: O) -> Result<TzEnv, ParseError>
Parse a POSIX TZ environment variable string from the given OsStr.