tzif6453%python.module
fault.time

Read TZif, time zone information, files(zic output).

WARNING

This module is intended for internal use only. The APIs are subject to change without notice.

os0
import

struct0
import

collections0
import

magic0
data

magic = b'TZif'

tzdir0
data

tzdir = '/usr/share/zoneinfo'

tzdefault0
data

tzdefault = '/etc/localtime'

tzenviron0
data

tzenviron = 'TZ'

header_fields0
data

header_fields = (
	'tzh_ttisgmtcnt',  # The number of UTC/local indicators stored in the file.
	'tzh_ttisstdcnt',  # The number of standard/wall indicators stored in the file.
	'tzh_leapcnt',     # The number of leap seconds for which data is stored in the file.
	'tzh_timecnt',     # The number of `transition times` for which data is stored in the file.
	'tzh_typecnt',     # The number of `local time types` for which data is stored in the file (must not be zero).
	'tzh_charcnt',     # The number of characters of `time zone abbreviation strings` stored in the file.
)

tzinfo_header0
data

tzinfo_header = collections.namedtuple('tzinfo_header', header_fields)

header_struct_v10
data

header_struct_v1 = struct.Struct("!" + (len(header_fields) * "l"))

header_struct_v20
data

header_struct_v2 = struct.Struct("!" + (len(header_fields) * "q"))

ttinfo_fields0
data

ttinfo_fields = (
	'tt_gmtoff',
	'tt_isdst',
	'tt_abbrind',
)

tzinfo_ttinfo0
data

tzinfo_ttinfo = collections.namedtuple('tzinfo_ttinfo', ttinfo_fields)

ttinfo_struct_v10
data

ttinfo_struct_v1 = struct.Struct("!lbb")

ttinfo_struct_v20
data

ttinfo_struct_v2 = struct.Struct("!qbb")

transtime_struct_v10
data

transtime_struct_v1 = struct.Struct("!l")

leappairs_struct_v10
data

leappairs_struct_v1 = struct.Struct("!ll")

transtime_struct_v20
data

transtime_struct_v2 = struct.Struct("!q")

leappairs_struct_v20
data

leappairs_struct_v2 = struct.Struct("!qq")

tzinfo0
data

tzinfo = collections.namedtuple('tzinfo', (
	'header',
	'transitional_times',
	'types',
	'typinfo'
))
tzinfo = collections.namedtuple('tzinfo', (
	'tz_abbrev',
	'tz_offset',
	'tz_isdst',
	'tz_isstd',
	'tz_isgmt',
))

parse_version_10
function

parse_version_1(data)

parse the raw data from a TZif file. 4-byte longs.

Returns tuple of: (transtimes, types, timetypinfo, leaps, isstd, isgmt, abbr) See tzfile(5) for information about the fields.

parse_version_2250%
function

parse_version_2(data)

parse the raw data from a version 2 TZif file. 8-byte longs.

Returns tuple of: (transtimes, types, timetypinfo, leaps, isstd, isgmt, abbr) See tzfile(5) for information about the fields.

parse183%
function

parse(data)

Given TZif data, identify the appropriate version and unpack the timezone information.

structure0
function

structure(tzif)

Given the parse fields from parse(), make a more accessible structure.

system_timezone_file10%
function

system_timezone_file(relativepath)

get_timezone_data0
function

get_timezone_data(filepath)

Get the structured timezone data out of the specified file.

abbreviations100%
function

abbreviations(tzdir)

Yield all abbreviations in the TZif files in the tzdir(/usr/share/zoneinfo).

abbreviation_map140%
function

abbreviation_map()

Generate and return a mapping of zone abbreviations to their particular offsets.

Using this should mean that you know that abbreviations are ambiguous. This function is provided to aid common cases and popular mappings.