1#!/usr/bin/perl
2
3use warnings;
4use strict;
5use Test::Inter;
6$::ti = new Test::Inter $0;
7require "tests.pl";
8
9our $dmt = new Date::Manip::TZ;
10our $obj = $dmt->base();
11$dmt->config("forcedate","now,America/New_York");
12
13sub test {
14   my(@test)=@_;
15   my @ret = $obj->_critical_date(@test);
16   return @ret;
17}
18
19#################################################################################
20# Rule    Syria   2008    max     -       Apr     Fri>=1  0:00    1:00    S
21# Rule    Syria   2008    max     -       Oct     1       0:00    0       -
22
23# Zone    Asia/Damascus   2:25:12 -       LMT     1920    # Dimashq
24#                         2:00    Syria   EE%sT
25
26# Asia/Damascus  Apr  1 21:59:59 2038 UTC = Thu Apr  1 23:59:59 2038 EET isdst=0
27# Asia/Damascus  Apr  1 22:00:00 2038 UTC = Fri Apr  2 01:00:00 2038 EEST isdst=1
28# Asia/Damascus  Sep 30 20:59:59 2038 UTC = Thu Sep 30 23:59:59 2038 EEST isdst=1
29# Asia/Damascus  Sep 30 21:00:00 2038 UTC = Thu Sep 30 23:00:00 2038 EET isdst=0
30# Asia/Damascus  Mar 31 21:59:59 2039 UTC = Thu Mar 31 23:59:59 2039 EET isdst=0
31# Asia/Damascus  Mar 31 22:00:00 2039 UTC = Fri Apr  1 01:00:00 2039 EEST isdst=1
32# Asia/Damascus  Sep 30 20:59:59 2039 UTC = Fri Sep 30 23:59:59 2039 EEST isdst=1
33# Asia/Damascus  Sep 30 21:00:00 2039 UTC = Fri Sep 30 23:00:00 2039 EET isdst=0
34# Asia/Damascus  Apr  5 21:59:59 2040 UTC = Thu Apr  5 23:59:59 2040 EET isdst=0
35
36#################################################################################
37# Rule    US      2007    max     -       Mar     Sun>=8  2:00    1:00    D
38# Rule    US      2007    max     -       Nov     Sun>=1  2:00    0       S
39
40# Zone America/New_York   -4:56:02 -      LMT     1883 Nov 18 12:03:58
41#                         -5:00   US      E%sT    1920
42#                         -5:00   NYC     E%sT    1942
43#                         -5:00   US      E%sT    1946
44#                         -5:00   NYC     E%sT    1967
45#                         -5:00   US      E%sT
46
47# America/New_York  Mar  8 06:59:59 2037 UTC = Mar  8 01:59:59 2037 EST isdst=0
48# America/New_York  Mar  8 07:00:00 2037 UTC = Mar  8 03:00:00 2037 EDT isdst=1
49# America/New_York  Nov  1 05:59:59 2037 UTC = Nov  1 01:59:59 2037 EDT isdst=1
50# America/New_York  Nov  1 06:00:00 2037 UTC = Nov  1 01:00:00 2037 EST isdst=0
51# America/New_York  Mar 14 06:59:59 2038 UTC = Mar 14 01:59:59 2038 EST isdst=0
52# America/New_York  Mar 14 07:00:00 2038 UTC = Mar 14 03:00:00 2038 EDT isdst=1
53# America/New_York  Nov  7 05:59:59 2038 UTC = Nov  7 01:59:59 2038 EDT isdst=1
54# America/New_York  Nov  7 06:00:00 2038 UTC = Nov  7 01:00:00 2038 EST isdst=0
55
56#################################################################################
57# Rule    Egypt   1995    max     -       Apr     lastFri  0:00s  1:00    S
58# Rule    Egypt   2008    max     -       Aug     lastThu 23:00s  0       -
59
60# Zone    Africa/Cairo    2:05:00 -       LMT     1900 Oct
61#                         2:00    Egypt   EE%sT
62
63# Africa/Cairo  Thu Apr 25 21:59:59 2030 UTC = Thu Apr 25 23:59:59 2030 EET isdst=0
64# Africa/Cairo  Thu Apr 25 22:00:00 2030 UTC = Fri Apr 26 01:00:00 2030 EEST isdst=1
65# Africa/Cairo  Thu Aug 29 20:59:59 2030 UTC = Thu Aug 29 23:59:59 2030 EEST isdst=1
66# Africa/Cairo  Thu Aug 29 21:00:00 2030 UTC = Thu Aug 29 23:00:00 2030 EET isdst=0
67# Africa/Cairo  Thu Apr 24 21:59:59 2031 UTC = Thu Apr 24 23:59:59 2031 EET isdst=0
68
69#################################################################################
70# Rule    StJohns 2007    max     -       Mar     Sun>=8  0:01    1:00    D
71# Rule    StJohns 2007    max     -       Nov     Sun>=1  0:01    0       S
72
73# Zone America/St_Johns   -3:30:52 -      LMT     1884
74#                         -3:30:52 StJohns N%sT   1918
75#                         -3:30:52 Canada N%sT    1919
76#                         -3:30:52 StJohns N%sT   1935 Mar 30
77#                         -3:30   StJohns N%sT    1942 May 11
78#                         -3:30   Canada  N%sT    1946
79#                         -3:30   StJohns N%sT
80
81# America/St_Johns  Mar  8 03:30:59 2037 UTC = Mar  8 00:00:59 2037 NST isdst=0
82# America/St_Johns  Mar  8 03:31:00 2037 UTC = Mar  8 01:01:00 2037 NDT isdst=1
83# America/St_Johns  Nov  1 02:30:59 2037 UTC = Nov  1 00:00:59 2037 NDT isdst=1
84# America/St_Johns  Nov  1 02:31:00 2037 UTC = Oct 31 23:01:00 2037 NST isdst=0
85
86#################################################################################
87# Rule    EU      1981    max     -       Mar     lastSun  1:00u  1:00    S
88# Rule    EU      1996    max     -       Oct     lastSun  1:00u  0       -
89
90# Zone America/Godthab    -3:26:56 -      LMT     1916 Jul 28 # Nuuk
91#                         -3:00   -       WGT     1980 Apr  6 2:00
92#                         -3:00   EU      WG%sT
93
94# America/Godthab  Mar 29 00:59:59 2037 UTC = Mar 28 21:59:59 2037 WGT isdst=0
95# America/Godthab  Mar 29 01:00:00 2037 UTC = Mar 28 23:00:00 2037 WGST isdst=1
96# America/Godthab  Oct 25 00:59:59 2037 UTC = Oct 24 22:59:59 2037 WGST isdst=1
97# America/Godthab  Oct 25 01:00:00 2037 UTC = Oct 24 22:00:00 2037 WGT isdst=0
98
99#################################################################################
100
101# YEAR MON FLAG NUM DOW ISDST TIME TIMETYPE STDOFF DSTOFF
102my $tests="
103
1042038 04 ge 1 5 1 00:00:00 w 02:00:00 03:00:00 =>
105   [ 2038 4 1 21 59 59 ]
106   [ 2038 4 1 23 59 59 ]
107   [ 2038 4 1 22 0 0 ]
108   [ 2038 4 2 1 0 0 ]
109
1102038 10 dom 1 - 0 00:00:00 w 02:00:00 03:00:00 =>
111   [ 2038 9 30 20 59 59 ]
112   [ 2038 9 30 23 59 59 ]
113   [ 2038 9 30 21 0 0 ]
114   [ 2038 9 30 23 0 0 ]
115
1162037 03 ge 8 7 1 02:00:00 w -05:00:00 -04:00:00 =>
117   [ 2037 3 8 6 59 59 ]
118   [ 2037 3 8 1 59 59 ]
119   [ 2037 3 8 7 0 0 ]
120   [ 2037 3 8 3 0 0 ]
121
1222037 11 ge 1 7 0 02:00:00 w -05:00:00 -04:00:00 =>
123   [ 2037 11 1 5 59 59 ]
124   [ 2037 11 1 1 59 59 ]
125   [ 2037 11 1 6 0 0 ]
126   [ 2037 11 1 1 0 0 ]
127
1282030 04 last - 5 1 00:00:00 s 02:00:00 03:00:00 =>
129   [ 2030 4 25 21 59 59 ]
130   [ 2030 4 25 23 59 59 ]
131   [ 2030 4 25 22 0 0 ]
132   [ 2030 4 26 1 0 0 ]
133
1342030 08 last - 4 0 23:00:00 s 02:00:00 03:00:00 =>
135   [ 2030 8 29 20 59 59 ]
136   [ 2030 8 29 23 59 59 ]
137   [ 2030 8 29 21 0 0 ]
138   [ 2030 8 29 23 0 0 ]
139
1402037 03 ge 8 7 1 00:01:00 w -03:30:00 -02:30:00 =>
141   [ 2037 3 8 3 30 59 ]
142   [ 2037 3 8 0 0 59 ]
143   [ 2037 3 8 3 31 0 ]
144   [ 2037 3 8 1 1 0 ]
145
1462037 11 ge 1 7 0 00:01:00 w -03:30:00 -02:30:00 =>
147   [ 2037 11 1 2 30 59 ]
148   [ 2037 11 1 0 0 59 ]
149   [ 2037 11 1 2 31 0 ]
150   [ 2037 10 31 23 1 0 ]
151
1522037 03 last - 7 1 01:00:00 u -03:00:00 -02:00:00 =>
153   [ 2037 3 29 0 59 59 ]
154   [ 2037 3 28 21 59 59 ]
155   [ 2037 3 29 1 0 0 ]
156   [ 2037 3 28 23 0 0 ]
157
1582037 10 last - 7 0 01:00:00 u -03:00:00 -02:00:00 =>
159   [ 2037 10 25 0 59 59 ]
160   [ 2037 10 24 22 59 59 ]
161   [ 2037 10 25 1 0 0 ]
162   [ 2037 10 24 22 0 0 ]
163
164";
165
166$::ti->tests(func  => \&test,
167             tests => $tests);
168$::ti->done_testing();
169
170
171#Local Variables:
172#mode: cperl
173#indent-tabs-mode: nil
174#cperl-indent-level: 3
175#cperl-continued-statement-offset: 2
176#cperl-continued-brace-offset: 0
177#cperl-brace-offset: 0
178#cperl-brace-imaginary-offset: 0
179#cperl-label-offset: 0
180#End:
181