DateTime-TimeZone-SystemV-0.009000755001750001750 012217164626 16320 5ustar00zeframzefram000000000000DateTime-TimeZone-SystemV-0.009/.gitignore000444001750001750 20212217164617 20417 0ustar00zeframzefram000000000000/Build /Makefile /_build /blib /META.json /META.yml /MYMETA.json /MYMETA.yml /Makefile.PL /SIGNATURE /DateTime-TimeZone-SystemV-* DateTime-TimeZone-SystemV-0.009/MANIFEST000444001750001750 33212217164617 17564 0ustar00zeframzefram000000000000.gitignore Build.PL Changes MANIFEST META.json META.yml Makefile.PL README lib/DateTime/TimeZone/SystemV.pm t/construct.t t/ident.t t/local.t t/offset.t t/pod_cvg.t t/pod_syn.t SIGNATURE Added here by Module::Build DateTime-TimeZone-SystemV-0.009/Makefile.PL000444001750001750 230212217164617 20424 0ustar00zeframzefram000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.4007 require 5.006; unless (eval "use Module::Build::Compat 0.02; 1" ) { print "This module requires Module::Build to install itself.\n"; require ExtUtils::MakeMaker; my $yn = ExtUtils::MakeMaker::prompt (' Install Module::Build now from CPAN?', 'y'); unless ($yn =~ /^y/i) { die " *** Cannot install without Module::Build. Exiting ...\n"; } require Cwd; require File::Spec; require CPAN; # Save this 'cause CPAN will chdir all over the place. my $cwd = Cwd::cwd(); CPAN::Shell->install('Module::Build::Compat'); CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate or die "Couldn't install Module::Build, giving up.\n"; chdir $cwd or die "Cannot chdir() back to $cwd: $!"; } eval "use Module::Build::Compat 0.02; 1" or die $@; Module::Build::Compat->run_build_pl(args => \@ARGV); my $build_script = 'Build'; $build_script .= '.com' if $^O eq 'VMS'; exit(0) unless(-e $build_script); # cpantesters convention require Module::Build; Module::Build::Compat->write_makefile(build_class => 'Module::Build'); DateTime-TimeZone-SystemV-0.009/META.json000444001750001750 302612217164617 20077 0ustar00zeframzefram000000000000{ "abstract" : "System V and POSIX timezone strings", "author" : [ "Andrew Main (Zefram) " ], "dynamic_config" : 0, "generated_by" : "Module::Build version 0.4007, CPAN::Meta::Converter version 2.131560", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "DateTime-TimeZone-SystemV", "prereqs" : { "build" : { "requires" : { "Date::ISO8601" : "0", "Module::Build" : "0", "Test::More" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "configure" : { "requires" : { "Module::Build" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Date::ISO8601" : "0", "Params::Classify" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } } }, "provides" : { "DateTime::TimeZone::SystemV" : { "file" : "lib/DateTime/TimeZone/SystemV.pm", "version" : "0.009" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "git://git.fysh.org/zefram/DateTime-TimeZone-SystemV.git" } }, "version" : "0.009" } DateTime-TimeZone-SystemV-0.009/Build.PL000444001750001750 147312217164617 17756 0ustar00zeframzefram000000000000{ use 5.006; } use warnings; use strict; use Module::Build; Module::Build->new( module_name => "DateTime::TimeZone::SystemV", license => "perl", configure_requires => { "Module::Build" => 0, "perl" => "5.006", "strict" => 0, "warnings" => 0, }, build_requires => { "Date::ISO8601" => 0, "Module::Build" => 0, "Test::More" => 0, "perl" => "5.006", "strict" => 0, "warnings" => 0, }, requires => { "Carp" => 0, "Date::ISO8601" => 0, "Params::Classify" => 0, "perl" => "5.006", "strict" => 0, "warnings" => 0, }, dynamic_config => 0, meta_add => { distribution_type => "module" }, meta_merge => { resources => { repository => "git://git.fysh.org/zefram/". "DateTime-TimeZone-SystemV.git", }, }, create_makefile_pl => "passthrough", sign => 1, )->create_build_script; 1; DateTime-TimeZone-SystemV-0.009/META.yml000444001750001750 155112217164617 17730 0ustar00zeframzefram000000000000--- abstract: 'System V and POSIX timezone strings' author: - 'Andrew Main (Zefram) ' build_requires: Date::ISO8601: 0 Module::Build: 0 Test::More: 0 perl: 5.006 strict: 0 warnings: 0 configure_requires: Module::Build: 0 perl: 5.006 strict: 0 warnings: 0 dynamic_config: 0 generated_by: 'Module::Build version 0.4007, CPAN::Meta::Converter version 2.131560' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: DateTime-TimeZone-SystemV provides: DateTime::TimeZone::SystemV: file: lib/DateTime/TimeZone/SystemV.pm version: 0.009 requires: Carp: 0 Date::ISO8601: 0 Params::Classify: 0 perl: 5.006 strict: 0 warnings: 0 resources: license: http://dev.perl.org/licenses/ repository: git://git.fysh.org/zefram/DateTime-TimeZone-SystemV.git version: 0.009 DateTime-TimeZone-SystemV-0.009/README000444001750001750 154712217164617 17344 0ustar00zeframzefram000000000000NAME DateTime::TimeZone::SystemV - System V and POSIX timezone strings DESCRIPTION An instance of this class represents a timezone that was specified by means of a System V timezone recipe or the POSIX extended form of the same syntax. 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. INSTALLATION perl Build.PL ./Build ./Build test ./Build install AUTHOR Andrew Main (Zefram) COPYRIGHT Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013 Andrew Main (Zefram) LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. DateTime-TimeZone-SystemV-0.009/Changes000444001750001750 605112217164617 17752 0ustar00zeframzefram000000000000version 0.009; 2013-09-21 * bugfix: correct ->offset_for_local_datetime for perpetual-DST ruleset that can arise with the tzfile3 system version 0.008; 2013-09-20 * support the extended form of the recipe syntax that is used by version 3 of the tzfile(5) file format version 0.007; 2013-07-14 * bugfix: permit time of day for a DST change to extend up to 24:59:59, which POSIX (unclearly) permits and is actually seen in the current rule for timezone Asia/Amman * in META.{yml,json}, point to public git repository version 0.006; 2012-03-10 * eliminate use of Date::JD, because it's too heavy to justify the minimal convenience gained from it * in documentation, fully explicate the syntax for offsets and times of day in recipes * in documentation, describe the POSIX abbreviation length limit * in documentation, link to the POSIX definition of the TZ environment variable * in documentation, fix parameter summary for constructor * a little more testing of error cases * test behaviour around leap seconds * convert .cvsignore to .gitignore version 0.005; 2011-09-26 * support specifying a timezone name distinct from the recipe * include the local time and zone name in error message about non-existent local time * check argument types in constructor * in doc, use the word "recipe" to describe the timezone specification * make test suite work even if DateTime is not available * use new context-independent version of Date::JD function * include META.json in distribution * add MYMETA.json to .cvsignore version 0.004; 2010-07-30 * in documentation, use the term "truth value" instead of the less precise "boolean" * abandon use of the "fields" module * check for required Perl version at runtime * use full stricture in test suite * in Build.PL, explicitly declare configure-time requirements * remove bogus "exit 0" from Build.PL * add MYMETA.yml to .cvsignore version 0.003; 2009-03-22 * bugfix: cleanly reject non-ASCII digits in timezone specification * use "fields" module to structure object * test POD syntax and coverage, and rename an internal function to satisfy the coverage test * drop prototypes from method subs (where the prototypes have no effect) * in tests, avoid unreliable "\d" regexp element * typo fix in documentation * include "distribution_type" entry in META.yml to satisfy CPANTS * in documentation, separate "license" section from "copyright" section * use full stricture in Build.PL * remove from .cvsignore items that don't occur with Module::Build version 0.002; 2007-09-09 * bugfix: require bugfixed version of Date::JD (for $SIG{__DIE__} handling) * build with Module::Build instead of ExtUtils::MakeMaker * complete dependency list * include signature in distribution version 0.001; 2007-09-02 * avoid returning negative zero for offsets, which was confusing the test suite * move a misplaced ", in seconds" in the documentation version 0.000; 2007-02-04 * initial released version DateTime-TimeZone-SystemV-0.009/SIGNATURE000644001750001750 307712217164626 17752 0ustar00zeframzefram000000000000This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.73. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 6066e90a15cbd4f85f9d30eae2d2418e6a04df82 .gitignore SHA1 a649d27904981112fe84f182984f6e93eb1ceb0a Build.PL SHA1 2bd74138d1142689d758abf6a9e873ecdb2572cc Changes SHA1 dc8b2575c26fa85efdedbdacca82355a4ae4a0d2 MANIFEST SHA1 399ae1ab490c5b4cf8dda29330ac057c2eb5c74e META.json SHA1 fea052329190a8b09cc96e1759764e85cbf55be5 META.yml SHA1 0bfa106a64fc680e40507c47cbf461cea3a8b374 Makefile.PL SHA1 7a3be303a22b10857b598ef048f54ac9540682de README SHA1 e90ee756416d6f5fbdc15ed356505fd2fcd92161 lib/DateTime/TimeZone/SystemV.pm SHA1 68f34ea0ea69ac66e019a0e5d3c7585df4eba6e7 t/construct.t SHA1 8b35493343a2804f5c4fd38e2feed15999ee86a7 t/ident.t SHA1 d8665d4d4de5c2dde9f048cc5c142b9b67013ccf t/local.t SHA1 996d18b684cee524591f4b652ee7c506da4cf0c8 t/offset.t SHA1 904d9a4f76525e2303e4b0c168c68230f223c8de t/pod_cvg.t SHA1 65c75abdef6f01a5d1588a307f2ddfe2333dc961 t/pod_syn.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlI86Y8ACgkQOV9mt2VyAVEoxgCZAbWVlu0wlatnkAUrpWxu/8k2 o7wAoJ5Q/0u9ipGINXs8NDp9FhKc3hoJ =2st/ -----END PGP SIGNATURE----- DateTime-TimeZone-SystemV-0.009/lib000755001750001750 012217164617 17066 5ustar00zeframzefram000000000000DateTime-TimeZone-SystemV-0.009/lib/DateTime000755001750001750 012217164617 20562 5ustar00zeframzefram000000000000DateTime-TimeZone-SystemV-0.009/lib/DateTime/TimeZone000755001750001750 012217164617 22314 5ustar00zeframzefram000000000000DateTime-TimeZone-SystemV-0.009/lib/DateTime/TimeZone/SystemV.pm000444001750001750 4571112217164617 24451 0ustar00zeframzefram000000000000=head1 NAME DateTime::TimeZone::SystemV - System V and POSIX timezone strings =head1 SYNOPSIS 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); =head1 DESCRIPTION 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 L interface, so that its instances can be used with L objects. =head1 SYSTEM V TIMEZONE RECIPE SYSTEM 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 L file format. A timezone may be specified that has a fixed offset by the syntax "II", or a timezone with DST by the syntax "III[I]B<,>IB<,>I". "I" specifies an abbreviation by which an offset is known, "I" specifies the offset, and "I" 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, "B<+>", and "B<->". If it contains only ASCII alphabetic characters then the abbreviation specification "I" may be simply the abbreviation. Otherwise "I" must consist of the abbreviation wrapped in angle brackets ("B<< < >>...B<< > >>"). 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 C, 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), "I", 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 "B<+>", 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 L 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 "I" takes the form "I[BI]", where "I" is the rule giving the day on which the transition notionally takes place and "I" 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 L 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 "I" may take three forms. Firstly, "BI" means the month-day date that is the Ith day of a non-leap year. Thus "B" means the February 28 and "B" means March 1 (even in a leap year). February 29 cannot be specified this way. Secondly, if "I" is just a decimal number, it means the (1+I)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, "I" may have the form "BIB<.>IB<.>I" means day I of the Ith week of the Ith month. The day is given as a single digit, with "B<0>" meaning Sunday and "B<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 "I" is "B<5>" then the last week of the month (containing its last seven days) is used, rather than the fifth week (which is incomplete). Examples: =over =item MUT-4 Mauritius time, since 1907: 4 hours ahead of UT all year. =item EST5EDT,M3.2.0,M11.1.0 US Eastern timezone with DST, from 2007 onwards. 5 hours behind UT in winter and 4 hours behind in summer. Changes on the second Sunday in March and the first Sunday in November, in each case at 02:00 local time. =item NST3:30NDT,M3.2.0/0:01,M11.1.0/0:01 Newfoundland timezone with DST, from 2007 onwards. 3.5 hours behind UT in winter and 2.5 hours behind in summer. Changes on the second Sunday in March and the first Sunday in November, in each case at 00:01 local time. =item GMT0BST,M3.5.0/1,M10.5.0 UK civil time, from 1996 onwards. On UT during the winter, calling it "GMT", and 1 hour ahead of UT during the summer, called "BST". Changes on the last Sunday in March and the last Sunday in October, in each case at 01:00 UT. =item EST-10EST,M10.5.0,M3.5.0/3 Australian Eastern timezone, from 2007 onwards. 10 hours ahead of UT in the southern winter (the middle of the calendar year), and 11 hours ahead in the southern summer. Changes to DST on the last Sunday in October, and back on the last Sunday in March, in each case at 02:00 standard time (16:00 UT of the preceding day). =item EET-2EEST,M3.5.4/24,M9.3.6/145 Palestinian civil time, from 2012 onwards. 2 hours ahead of UT in winter and 3 hours ahead in summer. Changes at the end (24:00 local time) of the last Thursday in March and 01:00 local time on the Friday following the third Saturday in September (that is, the Friday falling between September 21 and September 27 inclusive). The extended time-of-day "145", meaning 01:00 of the day six days after the nominal day, is only valid in the L variant of the System V syntax. The time-of-day "24" is not so restricted, being permitted by POSIX. =back =cut package DateTime::TimeZone::SystemV; { use 5.006; } use warnings; use strict; use Carp qw(croak); use Date::ISO8601 0.000 qw(month_days ymd_to_cjdn present_ymd year_days cjdn_to_yd cjdn_to_ywd); use Params::Classify 0.000 qw(is_undef is_string); our $VERSION = "0.009"; my $rdn_epoch_cjdn = 1721425; my $abbrev_rx = qr#[A-Za-z]{3,}|\<[-+0-9A-Za-z]{3,}\>#; my $offset_rx = qr#[-+]?(?:2[0-4]|[01]?[0-9])(?::[0-5][0-9](?::[0-5][0-9])?)?#; my $rule_date_rx = qr#J0*(?:3(?:[0-5][0-9]|6[0-5])|[12]?[0-9][0-9]|[1-9]) |0*(?:3(?:[0-5][0-9]|6[0-4])|[12]?[0-9][0-9]|[0-9]) |M0*(?:1[0-2]|[1-9])\.0*[1-5]\.0*[0-6]#x; my $posix_rule_time_rx = qr#(?:2[0-4]|[01]?[0-9])(?::[0-5][0-9](?::[0-5][0-9])?)?#; my $tzfile3_rule_time_rx = qr#[-+]?(?:16[0-7]|1[0-5][0-9]|0[0-9][0-9]|[0-9]{1,2}) (?::[0-5][0-9](?::[0-5][0-9])?)?#x; my $posix_rule_dt_rx = qr#${rule_date_rx}(?:/${posix_rule_time_rx})?#o; my $tzfile3_rule_dt_rx = qr#${rule_date_rx}(?:/${tzfile3_rule_time_rx})?#o; my $posix_tz_rx = qr#${abbrev_rx}${offset_rx} (?:${abbrev_rx}(?:${offset_rx})? (?:,${posix_rule_dt_rx},${posix_rule_dt_rx})?)?#xo; my $tzfile3_tz_rx = qr#${abbrev_rx}${offset_rx} (?:${abbrev_rx}(?:${offset_rx})? (?:,${tzfile3_rule_dt_rx},${tzfile3_rule_dt_rx})?)?#xo; my %tz_rx = ( posix => $posix_tz_rx, tzfile3 => $tzfile3_tz_rx, ); sub _parse_abbrev($) { my($spec) = @_; return $spec =~ /\A\<(.*)\>\z/s ? $1 : $spec; } sub _parse_offset($) { my($spec) = @_; my($sign, $h, $m, $s) = ($spec =~ /\A([-+]?)([0-9]+)(?::([0-9]+)(?::([0-9]+))?)?\z/); return ($sign eq "-" ? 1 : -1) * ($h*3600 + (defined($m) ? $m*60 + (defined($s) ? $s : 0) : 0)) || 0; } sub _parse_rule($$) { my($spec, $offset) = @_; my($drule, $tod) = split(m#/#, $spec); return { drule => $drule, sod => -$offset + (defined($tod) ? -_parse_offset($tod) : 7200), }; } =head1 CONSTRUCTOR =over =item DateTime::TimeZone::SystemV->new(ATTR => VALUE, ...) Constructs and returns a L-compatible timezone object that implements the timezone described by the recipe given in the arguments. The following attributes may be given: =over =item B Name for the timezone object. This will be returned by the C method described below, and will be included in certain error messages. If not given, then the recipe is used as the timezone name. =item B The short textual timezone recipe, as described in L. Must be given. =item B Keyword identifying the particular variant of the recipe system according to which the recipe is to be interpreted. It may be: =over =item B (default) As specified by POSIX.1. =item B As specified by version 3 of the L file format. =back =back =item DateTime::TimeZone::SystemV->new(RECIPE) Simpler way to invoke the above constructor in the usual case. Only the recipe is given; it will be interpreted according to POSIX system, and the recipe will also be used as the timezone name. =cut sub new { my $class = shift; unshift @_, "recipe" if @_ == 1; my $self = bless({}, $class); my $recipe; my $system; while(@_) { my $attr = shift; my $value = shift; if($attr eq "name") { croak "timezone name specified redundantly" if exists $self->{name}; croak "timezone name must be a string" unless is_string($value); $self->{name} = $value; } elsif($attr eq "recipe") { croak "recipe specified redundantly" if defined $recipe; croak "recipe must be a string" unless is_string($value); $recipe = $value; } elsif($attr eq "system") { croak "system identifier specified redundantly" if defined $system; croak "system identifier must be a string" unless is_string($value); croak "system identifier not recognised" unless exists $tz_rx{$value}; $system = $value; } else { croak "unrecognised attribute `$attr'"; } } croak "recipe not specified" unless defined $recipe; $self->{name} = $recipe unless exists $self->{name}; $system = "posix" unless defined $system; croak "not a valid SysV-style timezone recipe" unless $recipe =~ /\A$tz_rx{$system}\z/; $recipe =~ /\A($abbrev_rx)($offset_rx)/og; my($std_abbrev, $std_offset) = ($1, $2); $self->{std_abbrev} = _parse_abbrev($std_abbrev); $self->{std_offset} = _parse_offset($std_offset); return $self if $recipe =~ /\G\z/gc; $recipe =~ /\G($abbrev_rx)($offset_rx)?/g; my($dst_abbrev, $dst_offset) = ($1, $2); $self->{dst_abbrev} = _parse_abbrev($dst_abbrev); $self->{dst_offset} = defined($dst_offset) ? _parse_offset($dst_offset) : $self->{std_offset} + 3600; my($start_rule, $end_rule); if($recipe =~ /\G,(.*),(.*)/g) { ($start_rule, $end_rule) = ($1, $2); } else { # default to US 1976 rules, which is what the ruleless # old SysV style specs were expected to do ($start_rule, $end_rule) = ("M4.5.0", "M10.5.0"); } $self->{start_rule} = _parse_rule($start_rule, $self->{std_offset}); $self->{end_rule} = _parse_rule($end_rule, $self->{dst_offset}); if($system eq "tzfile3" && $self->{start_rule}->{drule} =~ /\A(?:J0*1|0+)\z/ && $self->{start_rule}->{sod} == -$self->{std_offset} && $self->{end_rule}->{drule} =~ /\AJ0*365\z/ && $self->{end_rule}->{sod} == 86400-$self->{std_offset}) { delete $self->{$_} foreach qw(std_abbrev std_offset start_rule end_rule); } return $self; } =back =head1 METHODS These methods are all part of the L interface. See that class for the general meaning of these methods; the documentation below only comments on the specific behaviour of this class. =head2 Identification =over =item $tz->is_floating Returns false. =cut sub is_floating { 0 } =item $tz->is_utc Returns false. =cut sub is_utc { 0 } =item $tz->is_olson Returns false. =cut sub is_olson { 0 } =item $tz->category Returns C, because the category concept doesn't properly apply to these timezones. =cut sub category { undef } =item $tz->name Returns the timezone name. Usually this is the recipe that was supplied to the constructor, but it can be overridden by the constructor's B attribute. =cut sub name { $_[0]->{name} } =back =head2 Offsets =over =item $tz->has_dst_changes Returns a truth value indicating whether the timezone includes a DST offset. =cut sub has_dst_changes { exists $_[0]->{dst_abbrev} } =item $tz->is_dst_for_datetime(DT) I
must be a L-compatible object (specifically, it must implement the C method). Returns a truth value indicating whether the timezone is on DST at the instant represented by I
. =cut sub _rule_doy($$) { my($drule, $year) = @_; if($drule =~ /\AJ([0-9]+)\z/) { my $j = $1; if($j < 60) { return $j; } else { return year_days($year) - 365 + $j; } } elsif($drule =~ /\A([0-9]+)\z/) { return 1 + $1; } elsif($drule =~ /\AM([0-9]+)\.([0-9]+)\.([0-9]+)\z/) { my($m, $w, $dow) = ($1, $2, $3); my $fdom = ($w == 5 ? month_days($year, $m) : $w*7) - 6; my(undef, undef, $fdow) = cjdn_to_ywd(ymd_to_cjdn($year, $m, $fdom)); my $dom = $fdom + ($dow + 7 - $fdow) % 7; my(undef, $doy) = cjdn_to_yd(ymd_to_cjdn($year, $m, $dom)); return $doy; } else { die "internal error: unrecognised day rule"; } } sub _is_dst_for_utc_rdn_sod { my($self, $rdn, $sod) = @_; my($year, $doy) = cjdn_to_yd($rdn + $rdn_epoch_cjdn); my $soy = $doy * 86400 + $sod; my @latest_change; foreach my $change_type (qw(end_rule start_rule)) { for(my $y = $year+1, my $doff = year_days($year); ; $doff -= year_days(--$y)) { my $change_soy = ($doff + _rule_doy($self->{$change_type} ->{drule}, $y)) * 86400 + $self->{$change_type}->{sod}; if($change_soy <= $soy) { push @latest_change, $change_soy; last; } } } return $latest_change[1] > $latest_change[0]; } sub is_dst_for_datetime { my($self, $dt) = @_; return 0 unless exists $self->{dst_abbrev}; return 1 unless exists $self->{std_abbrev}; my($utc_rdn, $utc_sod) = $dt->utc_rd_values; $utc_sod = 86399 if $utc_sod >= 86400; return $self->_is_dst_for_utc_rdn_sod($utc_rdn, $utc_sod); } =item $tz->offset_for_datetime(DT) I
must be a L-compatible object (specifically, it must implement the C method). Returns the offset from UT that is in effect at the instant represented by I
, in seconds. =cut sub offset_for_datetime { my($self, $dt) = @_; return $self->{$self->is_dst_for_datetime($dt) ? "dst_offset" : "std_offset"}; } =item $tz->short_name_for_datetime(DT) I
must be a L-compatible object (specifically, it must implement the C method). Returns the time scale abbreviation for the offset that is in effect at the instant represented by I
. =cut sub short_name_for_datetime { my($self, $dt) = @_; return $self->{$self->is_dst_for_datetime($dt) ? "dst_abbrev" : "std_abbrev"}; } =item $tz->offset_for_local_datetime(DT) I
must be a L-compatible object (specifically, it must implement the C method). Takes the local time represented by I
(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 I
). 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 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 Cs saying so. =cut sub _local_to_utc_rdn_sod($$$) { my($rdn, $sod, $offset) = @_; $sod -= $offset; while($sod < 0) { $rdn--; $sod += 86400; } while($sod >= 86400) { $rdn++; $sod -= 86400; } return ($rdn, $sod); } sub _is_dst_for_local_datetime { my($self, $dt) = @_; return 0 unless exists $self->{dst_abbrev}; return 1 unless exists $self->{std_abbrev}; my($lcl_rdn, $lcl_sod) = $dt->local_rd_values; $lcl_sod = 86399 if $lcl_sod >= 86400; my($std_rdn, $std_sod) = _local_to_utc_rdn_sod($lcl_rdn, $lcl_sod, $self->{std_offset}); my($dst_rdn, $dst_sod) = _local_to_utc_rdn_sod($lcl_rdn, $lcl_sod, $self->{dst_offset}); my $std_ok = !$self->_is_dst_for_utc_rdn_sod($std_rdn, $std_sod); my $dst_ok = $self->_is_dst_for_utc_rdn_sod($dst_rdn, $dst_sod); if($std_ok) { if($dst_ok) { return $self->{std_offset} > $self->{dst_offset}; } else { return 0; } } else { if($dst_ok) { return 1; } else { croak "local time @{[ present_ymd($lcl_rdn + $rdn_epoch_cjdn) ]}T@{[ sprintf(q(%02d:%02d:%02d), int($lcl_sod/3600), int($lcl_sod/60)%60, $lcl_sod%60) ]} does not exist in the @{[$self->{name}]} timezone ". "due to offset change"; } } } sub offset_for_local_datetime { my($self, $dt) = @_; return $self->{$self->_is_dst_for_local_datetime($dt) ? "dst_offset" : "std_offset"}; } =back =head1 SEE ALSO L, L, L, L =head1 AUTHOR Andrew Main (Zefram) =head1 COPYRIGHT Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013 Andrew Main (Zefram) =head1 LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; DateTime-TimeZone-SystemV-0.009/t000755001750001750 012217164617 16563 5ustar00zeframzefram000000000000DateTime-TimeZone-SystemV-0.009/t/pod_syn.t000444001750001750 23612217164617 20541 0ustar00zeframzefram000000000000use warnings; use strict; use Test::More; plan skip_all => "Test::Pod not available" unless eval "use Test::Pod 1.00; 1"; Test::Pod::all_pod_files_ok(); 1; DateTime-TimeZone-SystemV-0.009/t/construct.t000444001750001750 527712217164617 21144 0ustar00zeframzefram000000000000use warnings; use strict; use Test::More tests => 36; require_ok "DateTime::TimeZone::SystemV"; my $tz; $tz = DateTime::TimeZone::SystemV->new("EST5EDT"); ok $tz; is $tz->name, "EST5EDT"; $tz = DateTime::TimeZone::SystemV->new(recipe => "EST5EDT"); ok $tz; is $tz->name, "EST5EDT"; $tz = DateTime::TimeZone::SystemV->new(recipe => "EST5EDT", name => "foobar"); ok $tz; is $tz->name, "foobar"; $tz = DateTime::TimeZone::SystemV->new(name => "foobar", recipe => "EST5EDT"); ok $tz; is $tz->name, "foobar"; eval { DateTime::TimeZone::SystemV->new(); }; like $@, qr/\Arecipe not specified\b/; eval { DateTime::TimeZone::SystemV->new(name => "foobar"); }; like $@, qr/\Arecipe not specified\b/; eval { DateTime::TimeZone::SystemV->new(quux => "foobar"); }; like $@, qr/\Aunrecognised attribute\b/; eval { DateTime::TimeZone::SystemV->new(name => "foobar", name => "quux"); }; like $@, qr/\Atimezone name specified redundantly\b/; eval { DateTime::TimeZone::SystemV->new(recipe => "EST5EDT", recipe => "EST5EDT"); }; like $@, qr/\Arecipe specified redundantly\b/; eval { DateTime::TimeZone::SystemV->new(system => "posix", system => "posix"); }; like $@, qr/\Asystem identifier specified redundantly\b/; foreach( undef, [], *STDOUT, bless({}), ) { eval { DateTime::TimeZone::SystemV->new(name => $_) }; like $@, qr/\Atimezone name must be a string\b/; eval { DateTime::TimeZone::SystemV->new(recipe => $_) }; like $@, qr/\Arecipe must be a string\b/; eval { DateTime::TimeZone::SystemV->new(system => $_) }; like $@, qr/\Asystem identifier must be a string\b/; } eval { DateTime::TimeZone::SystemV->new(system => "foobar"); }; like $@, qr/\Asystem identifier not recognised\b/; eval { DateTime::TimeZone::SystemV->new(recipe => "EST"); }; like $@, qr/\Anot a valid SysV-style timezone recipe\b/; eval { DateTime::TimeZone::SystemV->new(recipe => "EST", system => "posix"); }; like $@, qr/\Anot a valid SysV-style timezone recipe\b/; eval { DateTime::TimeZone::SystemV->new(recipe => "EST", system => "tzfile3"); }; like $@, qr/\Anot a valid SysV-style timezone recipe\b/; eval { DateTime::TimeZone::SystemV->new(recipe => "EST5EDT", system => "posix"); }; is $@, ""; eval { DateTime::TimeZone::SystemV->new(recipe => "EST5EDT", system => "tzfile3"); }; is $@, ""; eval { DateTime::TimeZone::SystemV->new( recipe => "EET-2EEST,M3.5.4/24,M9.3.6/145"); }; like $@, qr/\Anot a valid SysV-style timezone recipe\b/; eval { DateTime::TimeZone::SystemV->new( recipe => "EET-2EEST,M3.5.4/24,M9.3.6/145", system => "posix"); }; like $@, qr/\Anot a valid SysV-style timezone recipe\b/; eval { DateTime::TimeZone::SystemV->new( recipe => "EET-2EEST,M3.5.4/24,M9.3.6/145", system => "tzfile3"); }; is $@, ""; 1; DateTime-TimeZone-SystemV-0.009/t/ident.t000444001750001750 100112217164617 20200 0ustar00zeframzefram000000000000use warnings; use strict; use Test::More tests => 15; require_ok "DateTime::TimeZone::SystemV"; my $tz; $tz = DateTime::TimeZone::SystemV->new("EST5"); ok $tz; ok !$tz->is_floating; ok !$tz->is_utc; ok !$tz->is_olson; is $tz->category, undef; is $tz->name, "EST5"; ok !$tz->has_dst_changes; $tz = DateTime::TimeZone::SystemV->new(name => "foo", recipe => "EST5EDT"); ok $tz; ok !$tz->is_floating; ok !$tz->is_utc; ok !$tz->is_olson; is $tz->category, undef; is $tz->name, "foo"; ok $tz->has_dst_changes; 1; DateTime-TimeZone-SystemV-0.009/t/pod_cvg.t000444001750001750 27312217164617 20510 0ustar00zeframzefram000000000000use warnings; use strict; use Test::More; plan skip_all => "Test::Pod::Coverage not available" unless eval "use Test::Pod::Coverage; 1"; Test::Pod::Coverage::all_pod_coverage_ok(); 1; DateTime-TimeZone-SystemV-0.009/t/local.t000444001750001750 606212217164617 20203 0ustar00zeframzefram000000000000use warnings; use strict; use Test::More tests => 101; { package FakeLocalDateTime; use Date::ISO8601 0.000 qw(ymd_to_cjdn); my $rdn_epoch_cjdn = 1721425; sub new { my($class, $y, $mo, $d, $h, $mi, $s) = @_; return bless({ rdn => ymd_to_cjdn($y, $mo, $d) - $rdn_epoch_cjdn, sod => 3600*$h + 60*$mi + $s, }, $class); } sub local_rd_values { ($_[0]->{rdn}, $_[0]->{sod}, 0) } } require_ok "DateTime::TimeZone::SystemV"; my $tz; sub try($$) { my($timespec, $offset) = @_; $timespec =~ /\A([0-9]{4})-([0-9]{2})-([0-9]{2})T ([0-9]{2}):([0-9]{2}):([0-9]{2})\z/x or die; my $dt = FakeLocalDateTime->new("$1", "$2", "$3", "$4", "$5", "$6"); is eval { $tz->offset_for_local_datetime($dt) }, $offset; unless(defined $offset) { like $@, qr/\A local\ time\ \Q$timespec\E\ does\ not\ exist \ in\ the\ [!-~]+\ timezone\ due\ to\ offset\ change \b/x; } } # constant offset $tz = DateTime::TimeZone::SystemV->new("EST5"); try "2004-12-31T19:00:00", -18000; try "2005-03-03T01:00:00", -18000; try "2005-06-07T04:01:10", -18000; try "2005-09-20T07:00:00", -18000; try "2005-11-02T15:00:00", -18000; try "2005-12-31T18:59:59", -18000; # default DST rules, and inverted version of default DST rules foreach("EST5EDT", "EDT4EST5,M10.5.0,M4.5.0") { $tz = DateTime::TimeZone::SystemV->new($_); try "2004-12-31T19:00:00", -18000; try "2005-03-03T01:00:00", -18000; try "2005-04-23T23:00:00", -18000; try "2005-04-23T23:59:59", -18000; try "2005-04-24T00:00:00", -18000; try "2005-04-24T00:59:59", -18000; try "2005-04-24T01:00:00", -18000; try "2005-04-24T01:59:59", -18000; try "2005-04-24T02:00:00", undef; try "2005-04-24T02:59:59", undef; try "2005-04-24T03:00:00", -14400; try "2005-04-24T03:59:59", -14400; try "2005-04-24T04:00:00", -14400; try "2005-04-24T04:59:59", -14400; try "2005-04-24T05:00:00", -14400; try "2005-04-24T05:59:59", -14400; try "2005-04-24T19:59:59", -14400; try "2005-04-24T20:00:00", -14400; try "2005-04-24T23:59:59", -14400; try "2005-04-25T00:00:00", -14400; try "2005-04-25T00:59:59", -14400; try "2005-04-25T01:00:00", -14400; try "2005-06-07T05:01:10", -14400; try "2005-09-20T08:00:00", -14400; try "2005-10-30T00:00:00", -14400; try "2005-10-30T00:59:59", -14400; try "2005-10-30T01:00:00", -18000; try "2005-10-30T01:59:59", -18000; try "2005-10-30T02:00:00", -18000; try "2005-10-30T02:59:59", -18000; try "2005-10-30T03:00:00", -18000; try "2005-10-30T03:59:59", -18000; try "2005-10-30T04:00:00", -18000; try "2005-10-30T04:59:59", -18000; try "2005-10-30T18:59:59", -18000; try "2005-10-30T19:00:00", -18000; try "2005-10-30T22:59:59", -18000; try "2005-10-30T23:00:00", -18000; try "2005-10-30T23:59:59", -18000; try "2005-10-31T00:00:00", -18000; try "2005-11-02T15:00:00", -18000; try "2005-12-31T18:59:59", -18000; try "2004-12-31T19:00:00", -18000; } # perpetual DST $tz = DateTime::TimeZone::SystemV->new(system => "tzfile3", recipe => "AAA-2BBB,J1/0,J365/25"); try "2005-01-01T00:00:00", +10800; try "2005-04-01T00:00:00", +10800; try "2005-08-01T00:00:00", +10800; try "2005-12-01T00:00:00", +10800; 1; DateTime-TimeZone-SystemV-0.009/t/offset.t000444001750001750 3554512217164617 20427 0ustar00zeframzefram000000000000use warnings; use strict; use Test::More tests => 817; { package FakeUtcDateTime; use Date::ISO8601 0.000 qw(ymd_to_cjdn); my $rdn_epoch_cjdn = 1721425; sub new { my($class, $y, $mo, $d, $h, $mi, $s) = @_; return bless({ rdn => ymd_to_cjdn($y, $mo, $d) - $rdn_epoch_cjdn, sod => 3600*$h + 60*$mi + $s, }, $class); } sub utc_rd_values { ($_[0]->{rdn}, $_[0]->{sod}, 0) } } require_ok "DateTime::TimeZone::SystemV"; my $tz; sub try($$$$) { my($timespec, $is_dst, $offset, $abbrev) = @_; $timespec =~ /\A([0-9]{4})-([0-9]{2})-([0-9]{2})T ([0-9]{2}):([0-9]{2}):([0-9]{2})Z\z/x or die; my $dt = FakeUtcDateTime->new("$1", "$2", "$3", "$4", "$5", "$6"); is !!$tz->is_dst_for_datetime($dt), !!$is_dst, "is DST for $timespec"; is $tz->offset_for_datetime($dt), $offset, "offset for $timespec"; is $tz->short_name_for_datetime($dt), $abbrev, "abbrev for $timespec"; } # zero offsets foreach("GMT0", "GMT+0", "GMT-0") { $tz = DateTime::TimeZone::SystemV->new($_); try "2005-01-03T00:00:00Z", 0, +0, "GMT"; } $tz = DateTime::TimeZone::SystemV->new("AAA1BBB"); try "2005-04-24T09:00:00Z", 1, +0, "BBB"; # constant offset $tz = DateTime::TimeZone::SystemV->new("EST5"); try "2005-01-03T00:00:00Z", 0, -18000, "EST"; try "2005-03-03T06:00:00Z", 0, -18000, "EST"; try "2005-06-07T09:01:10Z", 0, -18000, "EST"; try "2005-09-20T12:00:00Z", 0, -18000, "EST"; try "2005-11-02T20:00:00Z", 0, -18000, "EST"; try "2005-12-29T23:59:59Z", 0, -18000, "EST"; # default DST rules $tz = DateTime::TimeZone::SystemV->new("EST5EDT"); try "2005-01-03T00:00:00Z", 0, -18000, "EST"; try "2005-03-03T06:00:00Z", 0, -18000, "EST"; try "2005-04-24T04:00:00Z", 0, -18000, "EST"; try "2005-04-24T04:59:59Z", 0, -18000, "EST"; try "2005-04-24T05:00:00Z", 0, -18000, "EST"; try "2005-04-24T05:59:59Z", 0, -18000, "EST"; try "2005-04-24T06:00:00Z", 0, -18000, "EST"; try "2005-04-24T06:59:59Z", 0, -18000, "EST"; try "2005-04-24T07:00:00Z", 1, -14400, "EDT"; try "2005-04-24T07:59:59Z", 1, -14400, "EDT"; try "2005-04-24T08:00:00Z", 1, -14400, "EDT"; try "2005-04-24T08:59:59Z", 1, -14400, "EDT"; try "2005-04-24T09:00:00Z", 1, -14400, "EDT"; try "2005-04-24T09:59:59Z", 1, -14400, "EDT"; try "2005-04-24T23:59:59Z", 1, -14400, "EDT"; try "2005-04-25T00:00:00Z", 1, -14400, "EDT"; try "2005-04-25T03:59:59Z", 1, -14400, "EDT"; try "2005-04-25T04:00:00Z", 1, -14400, "EDT"; try "2005-04-25T04:59:59Z", 1, -14400, "EDT"; try "2005-04-25T05:00:00Z", 1, -14400, "EDT"; try "2005-06-07T09:01:10Z", 1, -14400, "EDT"; try "2005-09-20T12:00:00Z", 1, -14400, "EDT"; try "2005-10-30T04:00:00Z", 1, -14400, "EDT"; try "2005-10-30T04:59:59Z", 1, -14400, "EDT"; try "2005-10-30T05:00:00Z", 1, -14400, "EDT"; try "2005-10-30T05:59:59Z", 1, -14400, "EDT"; try "2005-10-30T06:00:00Z", 0, -18000, "EST"; try "2005-10-30T06:59:59Z", 0, -18000, "EST"; try "2005-10-30T07:00:00Z", 0, -18000, "EST"; try "2005-10-30T07:59:59Z", 0, -18000, "EST"; try "2005-10-30T08:00:00Z", 0, -18000, "EST"; try "2005-10-30T08:59:59Z", 0, -18000, "EST"; try "2005-10-30T09:00:00Z", 0, -18000, "EST"; try "2005-10-30T09:59:59Z", 0, -18000, "EST"; try "2005-10-30T23:59:59Z", 0, -18000, "EST"; try "2005-10-31T00:00:00Z", 0, -18000, "EST"; try "2005-10-31T03:59:59Z", 0, -18000, "EST"; try "2005-10-31T04:00:00Z", 0, -18000, "EST"; try "2005-10-31T04:59:59Z", 0, -18000, "EST"; try "2005-10-31T05:00:00Z", 0, -18000, "EST"; try "2005-11-02T20:00:00Z", 0, -18000, "EST"; try "2005-12-29T23:59:59Z", 0, -18000, "EST"; # complex offsets and change times, abbreviation quoting, and "J" rules $tz = DateTime::TimeZone::SystemV->new("<+A11>-5:30:45XYZ-6,J59/3:20,J60/9"); try "2004-01-03T00:00:00Z", 0, +19845, "+A11"; try "2004-02-27T00:00:00Z", 0, +19845, "+A11"; try "2004-02-27T21:30:00Z", 0, +19845, "+A11"; try "2004-02-27T21:49:14Z", 0, +19845, "+A11"; try "2004-02-27T21:49:15Z", 1, +21600, "XYZ"; try "2004-02-28T02:59:59Z", 1, +21600, "XYZ"; try "2004-02-28T03:00:00Z", 1, +21600, "XYZ"; try "2004-02-29T02:59:59Z", 1, +21600, "XYZ"; try "2004-02-29T03:00:00Z", 1, +21600, "XYZ"; try "2004-03-01T02:59:59Z", 1, +21600, "XYZ"; try "2004-03-01T03:00:00Z", 0, +19845, "+A11"; try "2004-03-02T02:59:59Z", 0, +19845, "+A11"; try "2004-03-02T03:00:00Z", 0, +19845, "+A11"; try "2004-12-29T23:59:59Z", 0, +19845, "+A11"; try "2005-01-03T00:00:00Z", 0, +19845, "+A11"; try "2005-02-27T00:00:00Z", 0, +19845, "+A11"; try "2005-02-27T21:30:00Z", 0, +19845, "+A11"; try "2005-02-27T21:49:14Z", 0, +19845, "+A11"; try "2005-02-27T21:49:15Z", 1, +21600, "XYZ"; try "2005-02-28T02:59:59Z", 1, +21600, "XYZ"; try "2005-02-28T03:00:00Z", 1, +21600, "XYZ"; try "2005-03-01T02:59:59Z", 1, +21600, "XYZ"; try "2005-03-01T03:00:00Z", 0, +19845, "+A11"; try "2005-03-02T02:59:59Z", 0, +19845, "+A11"; try "2005-03-02T03:00:00Z", 0, +19845, "+A11"; try "2005-12-29T23:59:59Z", 0, +19845, "+A11"; # "0" rules $tz = DateTime::TimeZone::SystemV->new("<+A11>-5:30:45XYZ-6,58/3:20,59/9"); try "2004-01-03T00:00:00Z", 0, +19845, "+A11"; try "2004-02-27T00:00:00Z", 0, +19845, "+A11"; try "2004-02-27T21:30:00Z", 0, +19845, "+A11"; try "2004-02-27T21:49:14Z", 0, +19845, "+A11"; try "2004-02-27T21:49:15Z", 1, +21600, "XYZ"; try "2004-02-28T02:59:59Z", 1, +21600, "XYZ"; try "2004-02-28T03:00:00Z", 1, +21600, "XYZ"; try "2004-02-29T02:59:59Z", 1, +21600, "XYZ"; try "2004-02-29T03:00:00Z", 0, +19845, "+A11"; try "2004-03-01T02:59:59Z", 0, +19845, "+A11"; try "2004-03-01T03:00:00Z", 0, +19845, "+A11"; try "2004-03-02T02:59:59Z", 0, +19845, "+A11"; try "2004-03-02T03:00:00Z", 0, +19845, "+A11"; try "2004-12-29T23:59:59Z", 0, +19845, "+A11"; try "2005-01-03T00:00:00Z", 0, +19845, "+A11"; try "2005-02-27T00:00:00Z", 0, +19845, "+A11"; try "2005-02-27T21:30:00Z", 0, +19845, "+A11"; try "2005-02-27T21:49:14Z", 0, +19845, "+A11"; try "2005-02-27T21:49:15Z", 1, +21600, "XYZ"; try "2005-02-28T02:59:59Z", 1, +21600, "XYZ"; try "2005-02-28T03:00:00Z", 1, +21600, "XYZ"; try "2005-03-01T02:59:59Z", 1, +21600, "XYZ"; try "2005-03-01T03:00:00Z", 0, +19845, "+A11"; try "2005-03-02T02:59:59Z", 0, +19845, "+A11"; try "2005-03-02T03:00:00Z", 0, +19845, "+A11"; try "2005-12-29T23:59:59Z", 0, +19845, "+A11"; # "+" in offset, and "M" rules $tz = DateTime::TimeZone::SystemV->new("AAA+3BBB,M3.2.3,M11.1.6"); try "2005-01-03T00:00:00Z", 0, -10800, "AAA"; try "2005-03-09T04:59:59Z", 0, -10800, "AAA"; try "2005-03-09T05:00:00Z", 1, -7200, "BBB"; try "2005-11-05T03:59:59Z", 1, -7200, "BBB"; try "2005-11-05T04:00:00Z", 0, -10800, "AAA"; try "2005-12-29T23:59:59Z", 0, -10800, "AAA"; # southern hemisphere DST $tz = DateTime::TimeZone::SystemV->new("AAA3BBB,M11.1.6,M3.2.3"); try "2005-01-03T00:00:00Z", 1, -7200, "BBB"; try "2005-03-09T03:59:59Z", 1, -7200, "BBB"; try "2005-03-09T04:00:00Z", 0, -10800, "AAA"; try "2005-11-05T04:59:59Z", 0, -10800, "AAA"; try "2005-11-05T05:00:00Z", 1, -7200, "BBB"; try "2005-12-29T23:59:59Z", 1, -7200, "BBB"; # DST offset lower than standard offset $tz = DateTime::TimeZone::SystemV->new("BBB2AAA3,M3.2.3,M11.1.6"); try "2005-01-03T00:00:00Z", 0, -7200, "BBB"; try "2005-03-09T03:59:59Z", 0, -7200, "BBB"; try "2005-03-09T04:00:00Z", 1, -10800, "AAA"; try "2005-11-05T04:59:59Z", 1, -10800, "AAA"; try "2005-11-05T05:00:00Z", 0, -7200, "BBB"; try "2005-12-29T23:59:59Z", 0, -7200, "BBB"; # DST change in following day $tz = DateTime::TimeZone::SystemV->new("AAA-2BBB,M3.5.4/24:30,M10.5.5/24:30"); try "2012-03-28T10:00:00Z", 0, 7200, "AAA"; try "2012-03-29T10:00:00Z", 0, 7200, "AAA"; try "2012-03-29T21:59:59Z", 0, 7200, "AAA"; try "2012-03-29T22:00:00Z", 0, 7200, "AAA"; try "2012-03-29T22:29:59Z", 0, 7200, "AAA"; try "2012-03-29T22:30:00Z", 1, 10800, "BBB"; try "2012-03-30T10:00:00Z", 1, 10800, "BBB"; try "2012-03-31T10:00:00Z", 1, 10800, "BBB"; try "2012-10-25T09:00:00Z", 1, 10800, "BBB"; try "2012-10-26T09:00:00Z", 1, 10800, "BBB"; try "2012-10-26T20:59:59Z", 1, 10800, "BBB"; try "2012-10-26T21:00:00Z", 1, 10800, "BBB"; try "2012-10-26T21:29:59Z", 1, 10800, "BBB"; try "2012-10-26T21:30:00Z", 0, 7200, "AAA"; try "2012-10-27T09:00:00Z", 0, 7200, "AAA"; try "2012-10-28T09:00:00Z", 0, 7200, "AAA"; # DST change with wildly extended time-of-day $tz = DateTime::TimeZone::SystemV->new(system => "tzfile3", recipe => "AAA-2BBB,M3.5.4/-160,M10.5.5/+160"); try "2012-03-21T00:00:00Z", 0, 7200, "AAA"; try "2012-03-22T00:00:00Z", 0, 7200, "AAA"; try "2012-03-22T05:59:59Z", 0, 7200, "AAA"; try "2012-03-22T06:00:00Z", 1, 10800, "BBB"; try "2012-03-23T00:00:00Z", 1, 10800, "BBB"; try "2012-03-28T00:00:00Z", 1, 10800, "BBB"; try "2012-03-29T00:00:00Z", 1, 10800, "BBB"; try "2012-03-30T00:00:00Z", 1, 10800, "BBB"; try "2012-03-31T00:00:00Z", 1, 10800, "BBB"; try "2012-10-25T00:00:00Z", 1, 10800, "BBB"; try "2012-10-27T00:00:00Z", 1, 10800, "BBB"; try "2012-10-31T00:00:00Z", 1, 10800, "BBB"; try "2012-11-01T00:00:00Z", 1, 10800, "BBB"; try "2012-11-01T12:59:59Z", 1, 10800, "BBB"; try "2012-11-01T13:00:00Z", 0, 7200, "AAA"; try "2012-11-02T00:00:00Z", 0, 7200, "AAA"; try "2012-11-03T00:00:00Z", 0, 7200, "AAA"; # change forward at end of year occurs in following UT year $tz = DateTime::TimeZone::SystemV->new("AAA24BBB-24,J365/12,J65/12"); try "2005-01-31T00:00:00Z", 1, +86400, "BBB"; try "2005-03-03T00:00:00Z", 1, +86400, "BBB"; try "2005-03-04T00:00:00Z", 1, +86400, "BBB"; try "2005-03-05T00:00:00Z", 1, +86400, "BBB"; try "2005-03-05T11:59:59Z", 1, +86400, "BBB"; try "2005-03-05T12:00:00Z", 0, -86400, "AAA"; try "2005-03-06T00:00:00Z", 0, -86400, "AAA"; try "2005-03-07T00:00:00Z", 0, -86400, "AAA"; try "2005-03-08T00:00:00Z", 0, -86400, "AAA"; try "2005-12-29T00:00:00Z", 0, -86400, "AAA"; try "2005-12-29T23:59:59Z", 0, -86400, "AAA"; try "2005-12-30T00:00:00Z", 0, -86400, "AAA"; try "2005-12-30T23:59:59Z", 0, -86400, "AAA"; try "2005-12-31T00:00:00Z", 0, -86400, "AAA"; try "2005-12-31T23:59:59Z", 0, -86400, "AAA"; try "2006-01-01T00:00:00Z", 0, -86400, "AAA"; try "2006-01-01T11:59:59Z", 0, -86400, "AAA"; try "2006-01-01T12:00:00Z", 1, +86400, "BBB"; try "2006-01-01T23:59:59Z", 1, +86400, "BBB"; try "2006-01-02T00:00:00Z", 1, +86400, "BBB"; try "2006-01-02T23:59:59Z", 1, +86400, "BBB"; try "2006-01-03T00:00:00Z", 1, +86400, "BBB"; try "2006-01-03T23:59:59Z", 1, +86400, "BBB"; # change back at start of year occurs in preceding UT year $tz = DateTime::TimeZone::SystemV->new("AAA24BBB-24,J65/12,J1/12"); try "2005-01-31T00:00:00Z", 0, -86400, "AAA"; try "2005-03-05T00:00:00Z", 0, -86400, "AAA"; try "2005-03-06T00:00:00Z", 0, -86400, "AAA"; try "2005-03-07T00:00:00Z", 0, -86400, "AAA"; try "2005-03-07T11:59:59Z", 0, -86400, "AAA"; try "2005-03-07T12:00:00Z", 1, +86400, "BBB"; try "2005-03-08T00:00:00Z", 1, +86400, "BBB"; try "2005-03-09T00:00:00Z", 1, +86400, "BBB"; try "2005-03-10T00:00:00Z", 1, +86400, "BBB"; try "2005-12-28T00:00:00Z", 1, +86400, "BBB"; try "2005-12-28T23:59:59Z", 1, +86400, "BBB"; try "2005-12-29T00:00:00Z", 1, +86400, "BBB"; try "2005-12-29T23:59:59Z", 1, +86400, "BBB"; try "2005-12-30T00:00:00Z", 1, +86400, "BBB"; try "2005-12-30T23:59:59Z", 1, +86400, "BBB"; try "2005-12-31T00:00:00Z", 1, +86400, "BBB"; try "2005-12-31T11:59:59Z", 1, +86400, "BBB"; try "2005-12-31T12:00:00Z", 0, -86400, "AAA"; try "2005-12-31T23:59:59Z", 0, -86400, "AAA"; try "2006-01-01T00:00:00Z", 0, -86400, "AAA"; try "2006-01-01T23:59:59Z", 0, -86400, "AAA"; try "2006-01-02T00:00:00Z", 0, -86400, "AAA"; try "2006-01-02T23:59:59Z", 0, -86400, "AAA"; # changes occur in different order from how it superficially appears $tz = DateTime::TimeZone::SystemV->new("AAA24BBB-24,J65/12,J66/12"); try "2005-01-31T00:00:00Z", 1, +86400, "BBB"; try "2005-03-04T00:00:00Z", 1, +86400, "BBB"; try "2005-03-05T00:00:00Z", 1, +86400, "BBB"; try "2005-03-06T00:00:00Z", 1, +86400, "BBB"; try "2005-03-06T11:59:59Z", 1, +86400, "BBB"; try "2005-03-06T12:00:00Z", 0, -86400, "AAA"; try "2005-03-06T23:59:59Z", 0, -86400, "AAA"; try "2005-03-07T00:00:00Z", 0, -86400, "AAA"; try "2005-03-07T11:59:59Z", 0, -86400, "AAA"; try "2005-03-07T12:00:00Z", 1, +86400, "BBB"; try "2005-03-07T23:59:59Z", 1, +86400, "BBB"; try "2005-03-08T00:00:00Z", 1, +86400, "BBB"; try "2005-03-09T00:00:00Z", 1, +86400, "BBB"; try "2005-12-01T00:00:00Z", 1, +86400, "BBB"; # changes occur in unexpected order across a year end $tz = DateTime::TimeZone::SystemV->new("AAA24BBB-24,J365/12,J1/12"); try "2005-12-01T00:00:00Z", 1, +86400, "BBB"; try "2005-12-29T00:00:00Z", 1, +86400, "BBB"; try "2005-12-30T00:00:00Z", 1, +86400, "BBB"; try "2005-12-31T00:00:00Z", 1, +86400, "BBB"; try "2005-12-31T11:59:59Z", 1, +86400, "BBB"; try "2005-12-31T12:00:00Z", 0, -86400, "AAA"; try "2005-12-31T23:59:59Z", 0, -86400, "AAA"; try "2006-01-01T00:00:00Z", 0, -86400, "AAA"; try "2006-01-01T11:59:59Z", 0, -86400, "AAA"; try "2006-01-01T12:00:00Z", 1, +86400, "BBB"; try "2006-01-01T23:59:59Z", 1, +86400, "BBB"; try "2006-01-02T00:00:00Z", 1, +86400, "BBB"; try "2006-01-03T00:00:00Z", 1, +86400, "BBB"; try "2006-01-31T00:00:00Z", 1, +86400, "BBB"; # perpetual DST $tz = DateTime::TimeZone::SystemV->new(system => "tzfile3", recipe => "AAA-2BBB,J1/0,J365/25"); try "2005-12-01T00:00:00Z", 1, +10800, "BBB"; try "2005-12-30T00:00:00Z", 1, +10800, "BBB"; try "2005-12-31T00:00:00Z", 1, +10800, "BBB"; try "2005-12-31T19:59:59Z", 1, +10800, "BBB"; try "2005-12-31T20:00:00Z", 1, +10800, "BBB"; try "2005-12-31T20:59:59Z", 1, +10800, "BBB"; try "2005-12-31T21:00:00Z", 1, +10800, "BBB"; try "2005-12-31T21:59:59Z", 1, +10800, "BBB"; try "2005-12-31T22:00:00Z", 1, +10800, "BBB"; try "2005-12-31T22:59:59Z", 1, +10800, "BBB"; try "2005-12-31T23:00:00Z", 1, +10800, "BBB"; try "2005-12-31T23:59:59Z", 1, +10800, "BBB"; try "2006-01-01T00:00:00Z", 1, +10800, "BBB"; try "2006-01-01T00:59:59Z", 1, +10800, "BBB"; try "2006-01-01T01:00:00Z", 1, +10800, "BBB"; try "2006-01-01T01:59:59Z", 1, +10800, "BBB"; try "2006-01-01T02:00:00Z", 1, +10800, "BBB"; try "2006-01-31T00:00:00Z", 1, +10800, "BBB"; # leap seconds, including changes occurring immediately after a leap second # (these are not real leap second dates) $tz = DateTime::TimeZone::SystemV->new("AAA-3BBB,M3.2.3/3,M11.1.6/4"); try "2005-02-01T12:00:00Z", 0, +10800, "AAA"; try "2005-02-01T23:59:59Z", 0, +10800, "AAA"; try "2005-02-01T23:59:60Z", 0, +10800, "AAA"; try "2005-02-02T00:00:00Z", 0, +10800, "AAA"; try "2005-02-02T12:00:00Z", 0, +10800, "AAA"; try "2005-03-08T12:00:00Z", 0, +10800, "AAA"; try "2005-03-08T23:59:59Z", 0, +10800, "AAA"; try "2005-03-08T23:59:60Z", 0, +10800, "AAA"; try "2005-03-09T00:00:00Z", 1, +14400, "BBB"; try "2005-03-09T12:00:00Z", 1, +14400, "BBB"; try "2005-04-01T12:00:00Z", 1, +14400, "BBB"; try "2005-04-01T23:59:59Z", 1, +14400, "BBB"; try "2005-04-01T23:59:60Z", 1, +14400, "BBB"; try "2005-04-02T00:00:00Z", 1, +14400, "BBB"; try "2005-04-02T12:00:00Z", 1, +14400, "BBB"; try "2005-11-04T12:00:00Z", 1, +14400, "BBB"; try "2005-11-04T23:59:59Z", 1, +14400, "BBB"; try "2005-11-04T23:59:60Z", 1, +14400, "BBB"; try "2005-11-05T00:00:00Z", 0, +10800, "AAA"; try "2005-11-05T12:00:00Z", 0, +10800, "AAA"; try "2005-12-01T12:00:00Z", 0, +10800, "AAA"; try "2005-12-01T23:59:59Z", 0, +10800, "AAA"; try "2005-12-01T23:59:60Z", 0, +10800, "AAA"; try "2005-12-02T00:00:00Z", 0, +10800, "AAA"; try "2005-12-02T12:00:00Z", 0, +10800, "AAA"; 1;