tzif-parser
tzif-parser is a Python library for parsing and handling Time Zone Information Format (TZif) files. These files are used to store time zone information, including transitions, UTC offsets, and daylight saving time information.
Features
- Parse TZif files and extract time zone information.
- Convert transition times to local wall and standard times.
- Read POSIX time zone strings.
Installation
To install tzif-parser, install it from PyPI using pip:
pip install tzif-parser
Usage
Here's an example of how to use tzif-parser to read a TZif file and extract time zone information:
from datetime import datetime
from tzif_parser import TimeZoneInfo
tz_info = TimeZoneInfo.read("America/New_York")
print(tz_info)
print(tz_info.header)
print(tz_info.body)
print(tz_info.footer)
current_transition = tz_info.body.find_transition(datetime.now())
Classes
TimeZoneInfo
Represents the time zone information parsed from a TZif file.
Properties
version: The version of the TZif file.header: The header data of the TZif file.body: The body data of the TZif file.footer: The POSIX time zone information.
TimeZoneInfoHeader
Represents the header data of a TZif file.
Properties
version: The version of the TZif file.is_utc_flag_count: The number of UTC/local indicators.wall_standard_flag_count: The number of standard/wall indicators.leap_second_transitions_count: The number of leap second transitions.transitions_count: The number of transition times.local_time_type_count: The number of local time types.timezone_abbrev_byte_count: The number of bytes used for time zone abbreviations.
TimeZoneInfoBody
Represents the body data of a TZif file.
Properties
transition_times: The list of transition times.leap_second_transitions: The list of leap second transitions.time_type_infos: The list of time type information.time_type_indices: The list of time type indices.timezone_abbrevs: The list of time zone abbreviations.wall_standard_flags: The list of standard/wall flags.is_utc_flags: The list of UTC/local flags.transitions: The list of time zone transitions.
TimeZoneTransition
Represents a single time zone transition.
Properties
transition_time_local_standard: The local standard time of the transition.transition_time_local_wall: The local wall time of the transition.transition_time_utc: The UTC time of the transition.abbreviation: The time zone abbreviation.utc_offset_secs: The UTC offset in seconds.utc_offset_hours: The UTC offset in hours.dst_difference_secs: The DST component of the offset in seconds.dst_difference_hours: The DST component of the offset in hours.is_dst: Whether the transition is during daylight saving time.wall_standard_flag: Metadata specifying whether the transition was originally provided in standard or wall time.is_utc: Metadata specifying whether the transition was originally provided in UTC or local time.
PosixTzInfo
Represents the POSIX time zone information.
Properties
posix_string: The POSIX time zone string.standard_abbrev: The standard time abbreviation.utc_offset_secs: The UTC offset in seconds.utc_offset_hours: The UTC offset in hours.dst_abbrev: The daylight saving time abbreviation.dst_offset_secs: The DST offset in seconds.dst_offset_hours: The DST offset in hours.dst_start: The start of daylight saving time.dst_end: The end of daylight saving time.dst_difference_secs: The difference between DST and standard time in seconds.dst_difference_hours: The difference between DST and standard time in hours.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.
Metadata
Release files for tzif-parser 0.0.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tzif_parser-0.0.16.tar.gz | 18.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tzif_parser-0.0.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.1 kB
Release files / tzif_parser-0.0.16.tar.gz
| Download URL | tzif_parser-0.0.16.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f723dfd8a8cea745cd2e437bab4009c6e28150f5a6ff91658cfd21f748d98760
|
|
BLAKE2b-256 checksum How to use checksums |
c0bfe058c4d572cf81af9482a87beec99d517d61e01f3a4819c01727a299331f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / tzif_parser-0.0.16-py3-none-any.whl
| Download URL | tzif_parser-0.0.16-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41a682f281492a19b8a8ae619d285d2b523eeeb822f4a33742f9d7f672629c6e
|
|
BLAKE2b-256 checksum How to use checksums |
8d096b898846d665e82a0a659b3a2d625c4201dea86c932d324f443885d6440b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|