Creates a zoneinfo file following a POSIX rule.
(tzstr, encoding="ascii")
| 286 | |
| 287 | |
| 288 | def zone_from_tzstr(tzstr, encoding="ascii"): |
| 289 | """Creates a zoneinfo file following a POSIX rule.""" |
| 290 | zonefile = io.BytesIO(_tzstr_header()) |
| 291 | zonefile.seek(0, 2) |
| 292 | |
| 293 | # Write the footer |
| 294 | zonefile.write(b"\x0a") |
| 295 | zonefile.write(tzstr.encode(encoding)) |
| 296 | zonefile.write(b"\x0a") |
| 297 | |
| 298 | zonefile.seek(0) |
| 299 | |
| 300 | return tz.tzfile(zonefile, key=tzstr) |
| 301 | |
| 302 | |
| 303 | @pytest.fixture |
no test coverage detected