DateTime::TimeZone::SystemV(3pm) | User Contributed Perl Documentation | DateTime::TimeZone::SystemV(3pm) |
DateTime::TimeZone::SystemV - System V and POSIX timezone strings
use DateTime::TimeZone::SystemV; $tz = DateTime::TimeZone::SystemV->new( name => "US Eastern", recipe => "EST5EDT,M3.2.0,M11.1.0"); $tz = DateTime::TimeZone::SystemV->new( "EST5EDT,M3.2.0,M11.1.0"); 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 specified by means of a System V timezone recipe or an extended form of the same syntax (such as that specified by POSIX). These can express a plain offset from Universal Time, or a system of two offsets (standard and daylight saving time) switching on a yearly cycle according to certain types of rule.
This class implements the DateTime::TimeZone interface, so that its instances can be used with DateTime objects.
This module supports multiple versions of the timezone recipe syntax derived from System V. Specifically, it supports the version specified by POSIX.1, and the extension of the POSIX format that is used by version 3 of the tzfile(5) file format.
A timezone may be specified that has a fixed offset by the syntax "aaaooo", or a timezone with DST by the syntax "aaaoooaaa[ooo],rrr,rrr". "aaa" specifies an abbreviation by which an offset is known, "ooo" specifies the offset, and "rrr" is a rule for when DST starts or ends. For backward compatibility, the rules part may also be omitted from a DST-using timezone, in which case some built-in default rules are used; don't rely on those rules being useful.
An abbreviation must be a string of three or more characters from ASCII alphanumerics, "+", and "-". If it contains only ASCII alphabetic characters then the abbreviation specification "aaa" may be simply the abbreviation. Otherwise "aaa" must consist of the abbreviation wrapped in angle brackets ("<...>"). The angle bracket form is always allowed. POSIX allows an implementation to set an upper limit on the length of timezone abbreviations. The limit is known as "TZNAME_MAX", and is required to be no less than 6 (characters/bytes). Abbreviations longer than 6 characters are therefore not portable. This class imposes no such limit.
An offset (from Universal Time), "ooo", is given in hours, or hours and minutes, or hours and minutes and seconds, with an optional preceding sign. Hours, minutes, and seconds must be separated by colons. The hours may be one or two digits, and the minutes and seconds must be two digits each. The maximum magnitude permitted is 24:59:59. The sign in the specification is the opposite of the sign of the actual offset. If no sign is given then the default is "+", meaning a timezone that is behind UT (or equal to UT if the offset is zero). If no DST offset is specified, it defaults to one hour ahead of the standard offset.
A DST-using timezone has one transition to DST and one transition to standard time in each Gregorian year. The transitions may be in either order within the year. If the transitions are in different orders from year to year then the behaviour is undefined; don't rely on it remaining the same in future versions. Likewise, the behaviour is generally undefined if transitions coincide. However, in the tzfile(5) variant, if the rules specify a transition to DST at 00:00 standard time on 1 January and a transition to standard time at 24:00 standard time on 31 December, which makes the transitions coincide with those of adjacent years, then the timezone is treated as observing DST all year.
A transition rule "rrr" takes the form "ddd[/ttt]", where "ddd" is the rule giving the day on which the transition notionally takes place and "ttt" is the time of day at which the transition takes place. (A time of day outside the usual 24-hour range can make the transition actually take place on a different day.) The time may be given in hours, or hours and minutes, or hours and minutes and seconds. Hours, minutes, and seconds must be separated by colons. The minutes and seconds must be two digits each. In the POSIX variant, the hours may be one or two digits, with no preceding sign, and the time stated may range from 00:00:00 to 24:59:59 (almost an hour into the following day). In the tzfile(5) variant, the hours may be one to three digits, with optional preceding sign, and the time stated may range from -167:59:59 to +167:59:59 (a span of a little over two weeks). If the time is not stated then it defaults to 02:00:00. The time for the transition to DST is interpreted according to the standard offset, and the time for the transition to standard time is interpreted according to the DST offset. (Thus normally the transition time is interpreted according to the offset that prevailed immediately before the transition.)
A day rule "ddd" may take three forms. Firstly, "Jnnn" means the month-day date that is the nnnth day of a non-leap year. Thus "J59" means the February 28 and "J60" means March 1 (even in a leap year). February 29 cannot be specified this way.
Secondly, if "ddd" is just a decimal number, it means the (1+ddd)th day of the year. February 29 counts in this case, and it is not possible to specify December 31 of a leap year.
Thirdly, "ddd" may have the form "Mm.w.d" means day d of the wth week of the mth month. The day is given as a single digit, with "0" meaning Sunday and "6" meaning Saturday. The first week contains days 1 to 7 of the month, the second week contains days 8 to 14, and so on. If "w" is "5" then the last week of the month (containing its last seven days) is used, rather than the fifth week (which is incomplete).
Examples:
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.
If the local time given is ambiguous due to a nearby offset change, the numerically lower offset (usually the standard one) is returned with no warning of the situation. If the local time given does not exist due to a nearby offset change, the method "die"s saying so.
DateTime, DateTime::TimeZone, POSIX.1 <http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html>, tzfile(5)
Andrew Main (Zefram) <zefram@fysh.org>
Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013, 2017 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.
2022-06-13 | perl v5.34.0 |