DateTime::TimeZone::Tzfile - tzfile (zoneinfo) timezone files
use DateTime::TimeZone::Tzfile; $tz = DateTime::TimeZone::Tzfile->new( name => "local timezone", filename => "/etc/localtime"); $tz = DateTime::TimeZone::Tzfile->new("/etc/localtime"); if($tz->is_floating) { ... if($tz->is_utc) { ... if($tz->is_olson) { ... $category = $tz->category; $tz_string = $tz->name; if($tz->has_dst_changes) { ... if($tz->is_dst_for_datetime($dt)) { ... $offset = $tz->offset_for_datetime($dt); $abbrev = $tz->short_name_for_datetime($dt); $offset = $tz->offset_for_local_datetime($dt);
An instance of this class represents a timezone that was encoded in a file in the tzfile(5) format. These can express arbitrary patterns of offsets from Universal Time, changing over time. Offsets and change times are limited to a resolution of one second.
This class implements the DateTime::TimeZone interface, so that its instances can be used with DateTime objects.
Reads and parses a tzfile(5) format file, then constructs and returns a DateTime-compatible timezone object that implements the timezone encoded in the file. The following attributes may be given:
Name for the timezone object. This will be returned by the name method described below, and will be included in certain error messages.
name
The string or undef that will be returned by the category method described below. Default undef.
undef
category
The truth value that will be returned by the is_olson method described below. Default false.
is_olson
Name of the file from which to read the timezone data. The filename must be understood by IO::File.
An IO::Handle object from which the timezone data can be read. This does not need to be a regular seekable file; it is read sequentially. After the constructor has finished, the handle can still be used to read any data that follows the timezone data.
Either a filename or filehandle must be given. If a timezone name is not given, then the filename is used instead if supplied; a timezone name must be given explicitly if no filename is given.
Simpler way to invoke the above constructor in the usual case. Only the filename is given; this will also be used as the timezone name.
These methods are all part of the DateTime::TimeZone interface. See that class for the general meaning of these methods; the documentation below only comments on the specific behaviour of this class.
Returns false.
Returns the truth value that was provided to the constructor for this purpose, default false. This nominally indicates whether the timezone data is from the Olson database. The files interpreted by this class are very likely to be from the Olson database, but there is no explicit indicator for this in the file, so this information must be supplied to the constructor if required.
Returns the value that was provided to the constructor for this purpose, default undef. This is intended to indicate the general region (continent or ocean) in which a geographical timezone is used, when the timezone is named according to the hierarchical scheme of the Olson timezone database.
Returns the timezone name. Usually this is the filename that was supplied to the constructor, but it can be overridden by the constructor's name attribute.
Returns a truth value indicating whether any of the observances in the file are marked as DST. These DST flags are potentially arbitrary, and don't affect any of the zone's behaviour.
DT must be a DateTime-compatible object (specifically, it must implement the utc_rd_values method). Returns the offset from UT that is in effect at the instant represented by DT, in seconds.
utc_rd_values
DT must be a DateTime-compatible object (specifically, it must implement the utc_rd_values method). Returns a truth value indicating whether the timezone's observance at the instant represented by DT is marked as DST. This DST flag is potentially arbitrary, and doesn't affect anything else.
DT must be a DateTime-compatible object (specifically, it must implement the utc_rd_values method). Returns the abbreviation used to label the time scale at the instant represented by DT. This abbreviation is potentially arbitrary, and does not uniquely identify either the timezone or the offset.
DT must be a DateTime-compatible object (specifically, it must implement the local_rd_values method). Takes the local time represented by DT (regardless of what absolute time it also represents), and interprets that as a local time in the timezone of the timezone object (not the timezone used in DT). Returns the offset from UT that is in effect at that local time, in seconds.
local_rd_values
If the local time given is ambiguous due to a nearby offset change, the numerically lowest offset (usually the standard one) is returned with no warning of the situation. (Equivalently: the latest possible absolute time is indicated.) If the local time given does not exist due to a nearby offset change, the method dies saying so.
die
DateTime, DateTime::TimeZone, DateTime::TimeZone::Olson, Time::OlsonTZ::Data, Time::OlsonTZ::Download, tzfile(5)
Andrew Main (Zefram) <zefram@fysh.org>
Copyright (C) 2007, 2009, 2010, 2011, 2012 Andrew Main (Zefram) <zefram@fysh.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DateTime::TimeZone::Tzfile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DateTime::TimeZone::Tzfile
CPAN shell
perl -MCPAN -e shell install DateTime::TimeZone::Tzfile
For more information on module installation, please visit the detailed CPAN module installation guide.