NAME
DateTime::TimeZone::Tzfile - tzfile (zoneinfo) timezone files
SYNOPSIS
use DateTime::TimeZone::Tzfile;
$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);
DESCRIPTION
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.
CONSTRUCTOR
- DateTime::TimeZone::Tzfile->new(FILENAME)
-
FILENAME must be a filename that can be interpreted by IO::File, and the file to which it refers must be in tzfile(5) format. Reads and parses the file, then constructs and returns a DateTime-compatible timezone object that implements the timezone encoded in the file.
METHODS
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.
Identification
- $tz->is_floating
-
Returns false.
- $tz->is_utc
-
Returns false.
- $tz->is_olson
-
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
andname
methods are not as would be expected for an Olson timezone. This behaviour may change in a future version. - $tz->category
-
Returns
undef
, because the category can't be determined from the file. - $tz->name
-
Returns the FILENAME that was supplied to the constructor.
Offsets
- $tz->has_dst_changes
-
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.
- $tz->offset_for_datetime(DT)
-
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. - $tz->is_dst_for_datetime(DT)
-
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. - $tz->short_name_for_datetime(DT)
-
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. - $tz->offset_for_local_datetime(DT)
-
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
die
s saying so.
SEE ALSO
DateTime, DateTime::TimeZone, tzfile(5)
AUTHOR
Andrew Main (Zefram) <zefram@fysh.org>
COPYRIGHT
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.