You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pubfnlocal() -> Result<Self,TzError>{#[cfg(not(unix))]let local_time_zone = Self::utc();#[cfg(unix)]let local_time_zone = Self::from_posix_tz("localtime")?;Ok(local_time_zone)}/// Construct a time zone from the contents of a time zone filepubfnfrom_tz_data(bytes:&[u8]) -> Result<Self,TzError>{parse_tz_file(bytes)}/// 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).pubfn from_posix_tz(tz_string:&str) -> Result<Self,TzError>{if tz_string.is_empty(){returnErr(TzError::TzStringError(TzStringError::InvalidTzString("empty TZ string")));}if tz_string == "localtime"{returnparse_tz_file(&fs::read("/etc/localtime")?);}let read = |mutfile:File| -> io::Result<_>{letmut bytes = Vec::new();
file.read_to_end(&mut bytes)?;Ok(bytes)};
The tzdata package is not installed in the docker, so the symlink /etc/localtime is either absent or broken.
In this case, the TimeZone::local() function returns an error, and you need to handle it in your code.
On non-UNIX platforms, since the path /etc/localtime is always invalid, the function always returns UTC.
Note: if you are willing to embed the time zone definitions in your binary, you can use the tzdb::local_tz function, which also works on Windows since it only queries for the current time zone name.
not find
/etc/localtime
file.about code:
ref: https://github.com/x-hgg-x/tz-rs/blob/master/src/timezone/mod.rs#L500-L518
The text was updated successfully, but these errors were encountered: