| DateTime::TimeZone::Tzfile - tzfile timezone files |
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 the DateTime::TimeZone manpage 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.
Name of the file from which to read the timezone data. The filename must be understood by the IO::File manpage.
An the IO::Handle manpage 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 filename 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 the DateTime::TimeZone manpage 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 false.
Returns false. The files interpreted by this class are actually very
likely to be from the Olson database, but false is returned to indicate
that the values returned by the category and name methods are not
as would be expected for an Olson timezone. This behaviour may change
in a future version.
Returns undef, because the category can't be determined from the file.
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 boolean 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.
DT must be a DateTime-compatible object (specifically, it must
implement the utc_rd_values method). Returns a boolean 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.
If the local time given is ambiguous due to a nearby offest 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.
DateTime, the DateTime::TimeZone manpage, tzfile(5)
Andrew Main (Zefram) <zefram@fysh.org>
Copyright (C) 2007 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.
| DateTime::TimeZone::Tzfile - tzfile timezone files |