NAME
Time::Tzfile - reads a binary tzfile into a hashref
VERSION
version 0.01
SYNOPSIS
use Time::Tzfile;
# will get 64bit timestamps if available
my $tzdata = Time::Tzfile->parse({filename => '/usr/share/zoneinfo/Europe/London'});
# will always get 32bit timestamps
my $tzdata = Time::Tzfile->parse({
filename => '/usr/share/zoneinfo/Europe/London',
use_version_one => 1,
});
METHODS
parse ({filename => /path/to/tzfile, use_version_one => 1})
The parse
takes a hashref containing the filename of the tzfile to open and optionally a flag to use the version one (32bit) tzfile entry. Returns a hashref containing the tzfile data.
Tzfiles can have two entries in them: the version one entry with 32bit timestamps and the version two entry with 64bit timestamps. If the tzfile has the version two entry, and if perl
is compiled with 64bit support, this method will automatically return the version two entry. If you want to force the version one entry, include the use_version_one
flag in the method arguments.
The hashref returned looks like this:
{
header => {}, # version and counts for the body
transitions => [], # historical timestamps when TZ changes occur
transition_idx => [], # index of ttinfo structs which apply to transitions
ttinfo_structs => [], # hashrefs of gmt offset, dst flag & the tz abbrev idx
tz_abbreviation=> $, # scalar of tz abbreviations (GMT, BST etc)
leap_seconds => [], # hashrefs of the timestamp & offset to apply leap secs
std_wall => [], # arrayref of std wall clock indicators
gmt_local => [], # arrayref of gm local indicators
}
I believe that all binary tzfiles are compiled with UTC timestamps, in which case you can ignore std_wall
and gmt_local
entries for calculating offsets.
See #SYNOPSIS for examples.
SEE ALSO
DateTime::TimeZone - automatically uses text versions of the Olsen db to calculate timezone offsets
DateTime::TimeZone::Tzfile - applies TZ offsets from binary tzfiles to DateTime objects
TZFILE FORMAT INFO
I found these resources useful guides to understanding the tzfile format
Tzfile manpage
Very useful description of tzfile format from Bloomberg
Wikipedia entry on the TZ database
AUTHOR
David Farrell <dfarrell@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2016 by David Farrell.
This is free software, licensed under:
The (two-clause) FreeBSD License