Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/offset/local/tz_info/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ impl TimeZone {

/// 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).
fn from_posix_tz(tz_string: &str) -> Result<Self, Error> {
// It is commonly agreed (but not standard) that setting an empty `TZ=` uses UTC.
if tz_string.is_empty() {
return Err(Error::InvalidTzString("empty TZ string"));
return Ok(Self::utc());
}

if tz_string == "localtime" {
Expand Down Expand Up @@ -925,7 +926,7 @@ mod tests {
}

assert!(TimeZone::from_posix_tz("EST5EDT,0/0,J365/25").is_err());
assert!(TimeZone::from_posix_tz("").is_err());
assert_eq!(TimeZone::from_posix_tz("").unwrap().find_local_time_type(0)?.offset(), 0);

Ok(())
}
Expand Down
Loading