Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions crates/stdlib/src/_zoneinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ mod _zoneinfo {
parser.bump();
}
let end = parser.i;
if end == start {
return None;
}
parser.bump();
return Some(String::from_utf8_lossy(&parser.bytes[start..end]).into_owned());
}
Expand Down
19 changes: 19 additions & 0 deletions extra_tests/snippets/stdlib_zoneinfo.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to stdlib_zoneinfo.py

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import io
import struct
from zoneinfo import ZoneInfo

from testutils import assert_raises

# Minimal TZif v3 data with no transitions and a POSIX rule in the footer.
header = (b"TZif3" + b"\0" * 15 + struct.pack(">6l", 0, 0, 0, 0, 0, 0)) * 2


def zone_from_rule(rule):
return ZoneInfo.from_file(io.BytesIO(header + b"\n" + rule + b"\n"))


for rule in (b"<>5", b"AAA4<>,M3.2.0/2,M11.1.0/3"):
assert_raises(ValueError, zone_from_rule, rule)

# Quoting still permits nonempty numeric abbreviations.
assert zone_from_rule(b"<+05>-5").tzname(None) == "+05"
Loading