| 269 | |
| 270 | @functools.cache |
| 271 | def _tzstr_header(): |
| 272 | out = bytearray() |
| 273 | # The TZif format always starts with a Version 1 file followed by |
| 274 | # the Version 2+ file. In this case, we have no transitions, just |
| 275 | # the tzstr in the footer, so up to the footer, the files are |
| 276 | # identical and we can just write the same file twice in a row. |
| 277 | for _ in range(2): |
| 278 | out += b"TZif" # Magic value |
| 279 | out += b"3" # Version |
| 280 | out += b" " * 15 # Reserved |
| 281 | |
| 282 | # We will not write any of the manual transition parts |
| 283 | out += struct.pack(">6l", 0, 0, 0, 0, 0, 0) |
| 284 | |
| 285 | return bytes(out) |
| 286 | |
| 287 | |
| 288 | def zone_from_tzstr(tzstr, encoding="ascii"): |