1<?php
2
3/*
4 * Note: test names match method names in a set of PHPUnit tests
5 * in a userland package.  Please be so kind as to leave them.
6 */
7
8date_default_timezone_set('America/New_York');
9
10
11/*
12 * Time, Fall, Zone Type 3 to Zone Type 2
13 *
14 * + prev: the day before the transition day  2010-11-06 18:38:28 EDT
15 * + dt: daylight time on transition day      2010-11-07 00:10:20 EDT
16 * + redodt: daylight time in the redo period 2010-11-07 01:12:33 EDT
17 * + redost: standard time in the redo period 2010-11-07 01:14:44 EST
18 * + st: standard time on the transition day  2010-11-07 03:16:55 EST
19 * + post: the day after the transition day   2010-11-08 19:59:59 EST
20 * + dtsec: daylight time 1 sec before change 2010-11-07 01:59:59 EDT
21 * + stsec: standard time first second        2010-11-07 01:00:00 EST
22 */
23echo "test_time_fall_type3_prev_type2_prev: ";
24$end   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
25$start = new DateTime('2010-10-04 02:18:48');  // sp prev, zt3
26examine_diff($end, $start, 'P+0Y1M2DT16H19M40S', 33);
27
28echo "test_time_fall_type3_prev_type2_dt: ";
29$end   = new DateTime('2010-11-07 00:10:20 EDT');  // dt, zt2
30$start = new DateTime('2010-11-06 18:38:28');  // prev, zt3
31examine_diff($end, $start, 'P+0Y0M0DT5H31M52S', 0);
32
33echo "test_time_fall_type3_prev_type2_redodt: ";
34$end   = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
35$end->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
36$start = new DateTime('2010-11-06 18:38:28');  // prev, zt3
37examine_diff($end, $start, 'P+0Y0M0DT6H34M5S', 0);
38
39echo "test_time_fall_type3_prev_type2_redost: ";
40$end   = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
41$end->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
42$start = new DateTime('2010-11-06 18:38:28');  // prev, zt3
43examine_diff($end, $start, 'P+0Y0M0DT7H36M16S', 0);
44
45echo "test_time_fall_type3_prev_type2_st: ";
46$end   = new DateTime('2010-11-07 03:16:55 EST');  // st, zt2
47$start = new DateTime('2010-11-06 18:38:28');  // prev, zt3
48examine_diff($end, $start, 'P+0Y0M0DT9H38M27S', 0);
49
50echo "test_time_fall_type3_prev_type2_post: ";
51$end   = new DateTime('2010-11-08 19:59:59 EST');  // post, zt2
52$start = new DateTime('2010-11-06 18:38:28');  // prev, zt3
53examine_diff($end, $start, 'P+0Y0M2DT1H21M31S', 2);
54
55echo "test_time_fall_type3_dt_type2_prev: ";
56$end   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
57$start = new DateTime('2010-11-07 00:10:20');  // dt, zt3
58examine_diff($end, $start, 'P-0Y0M0DT5H31M52S', 0);
59
60echo "test_time_fall_type3_dt_type2_dt: ";
61$end   = new DateTime('2010-11-07 00:15:35 EDT');  // sp dt, zt2
62$start = new DateTime('2010-11-07 00:10:20');  // dt, zt3
63examine_diff($end, $start, 'P+0Y0M0DT0H5M15S', 0);
64
65echo "test_time_fall_type3_dt_type2_redodt: ";
66$end   = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
67$start = new DateTime('2010-11-07 00:10:20');  // dt, zt3
68examine_diff($end, $start, 'P+0Y0M0DT1H2M13S', 0);
69
70echo "test_time_fall_type3_dt_type2_redost: ";
71$end   = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
72$start = new DateTime('2010-11-07 00:10:20');  // dt, zt3
73examine_diff($end, $start, 'P+0Y0M0DT2H4M24S', 0);
74
75echo "test_time_fall_type3_dt_type2_st: ";
76$end   = new DateTime('2010-11-07 03:16:55 EST');  // st, zt2
77$start = new DateTime('2010-11-07 00:10:20');  // dt, zt3
78examine_diff($end, $start, 'P+0Y0M0DT4H6M35S', 0);
79
80echo "test_time_fall_type3_dt_type2_post: ";
81$end   = new DateTime('2010-11-08 19:59:59 EST');  // post, zt2
82$start = new DateTime('2010-11-07 00:10:20');  // dt, zt3
83examine_diff($end, $start, 'P+0Y0M1DT20H49M39S', 1);
84
85echo "test_time_fall_type3_redodt_type2_prev: ";
86$end   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
87$start = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
88$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
89examine_diff($end, $start, 'P-0Y0M0DT6H34M5S', 0);
90
91echo "test_time_fall_type3_redodt_type2_dt: ";
92$end   = new DateTime('2010-11-07 00:10:20 EDT');  // dt, zt2
93$start = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
94$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
95examine_diff($end, $start, 'P-0Y0M0DT1H2M13S', 0);
96
97echo "test_time_fall_type3_redodt_type2_redodt: ";
98$end   = new DateTime('2010-11-07 01:15:35 EDT');  // sp redodt, zt2
99$start = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
100$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
101examine_diff($end, $start, 'P+0Y0M0DT0H3M2S', 0);
102
103echo "test_time_fall_type3_redodt_type2_redost: ";
104$end   = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
105$start = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
106$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
107examine_diff($end, $start, 'P+0Y0M0DT1H2M11S', 0);
108
109echo "test_time_fall_type3_redodt_type2_st: ";
110$end   = new DateTime('2010-11-07 03:16:55 EST');  // st, zt2
111$start = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
112$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
113examine_diff($end, $start, 'P+0Y0M0DT3H4M22S', 0);
114
115echo "test_time_fall_type3_redodt_type2_post: ";
116$end   = new DateTime('2010-11-08 19:59:59 EST');  // post, zt2
117$start = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
118$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
119examine_diff($end, $start, 'P+0Y0M1DT19H47M26S', 1);
120
121echo "test_time_fall_type3_redost_type2_prev: ";
122$end   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
123$start = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
124$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
125examine_diff($end, $start, 'P-0Y0M0DT7H36M16S', 0);
126
127echo "test_time_fall_type3_redost_type2_dt: ";
128$end   = new DateTime('2010-11-07 00:10:20 EDT');  // dt, zt2
129$start = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
130$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
131examine_diff($end, $start, 'P-0Y0M0DT2H4M24S', 0);
132
133echo "test_time_fall_type3_redost_type2_redodt: ";
134$end   = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
135$start = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
136$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
137examine_diff($end, $start, 'P-0Y0M0DT1H2M11S', 0);
138
139echo "test_time_fall_type3_redost_type2_redost: ";
140$end   = new DateTime('2010-11-07 01:16:54 EST');  // sp redodt, zt2
141$start = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
142$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
143examine_diff($end, $start, 'P+0Y0M0DT0H2M10S', 0);
144
145echo "test_time_fall_type3_redost_type2_st: ";
146$end   = new DateTime('2010-11-07 03:16:55 EST');  // st, zt2
147$start = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
148$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
149examine_diff($end, $start, 'P+0Y0M0DT2H2M11S', 0);
150
151echo "test_time_fall_type3_redost_type2_post: ";
152$end   = new DateTime('2010-11-08 19:59:59 EST');  // post, zt2
153$start = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
154$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
155examine_diff($end, $start, 'P+0Y0M1DT18H45M15S', 1);
156
157echo "test_time_fall_type3_st_type2_prev: ";
158$end   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
159$start = new DateTime('2010-11-07 03:16:55');  // st, zt3
160examine_diff($end, $start, 'P-0Y0M0DT9H38M27S', 0);
161
162echo "test_time_fall_type3_st_type2_dt: ";
163$end   = new DateTime('2010-11-07 00:10:20 EDT');  // dt, zt2
164$start = new DateTime('2010-11-07 03:16:55');  // st, zt3
165examine_diff($end, $start, 'P-0Y0M0DT4H6M35S', 0);
166
167echo "test_time_fall_type3_st_type2_redodt: ";
168$end   = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
169$start = new DateTime('2010-11-07 03:16:55');  // st, zt3
170examine_diff($end, $start, 'P-0Y0M0DT3H4M22S', 0);
171
172echo "test_time_fall_type3_st_type2_redost: ";
173$end   = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
174$start = new DateTime('2010-11-07 03:16:55');  // st, zt3
175examine_diff($end, $start, 'P-0Y0M0DT2H2M11S', 0);
176
177echo "test_time_fall_type3_st_type2_st: ";
178$end   = new DateTime('2010-11-07 05:19:56 EST');  // sp st, zt2
179$start = new DateTime('2010-11-07 03:16:55');  // st, zt3
180examine_diff($end, $start, 'P+0Y0M0DT2H3M1S', 0);
181
182echo "test_time_fall_type3_st_type2_post: ";
183$end   = new DateTime('2010-11-08 19:59:59 EST');  // post, zt2
184$start = new DateTime('2010-11-07 03:16:55');  // st, zt3
185examine_diff($end, $start, 'P+0Y0M1DT16H43M4S', 1);
186
187echo "test_time_fall_type3_post_type2_prev: ";
188$end   = new DateTime('2010-11-06 18:38:28 EDT');  // prev, zt2
189$start = new DateTime('2010-11-08 19:59:59');  // post, zt3
190examine_diff($end, $start, 'P-0Y0M2DT1H21M31S', 2);
191
192echo "test_time_fall_type3_post_type2_dt: ";
193$end   = new DateTime('2010-11-07 00:10:20 EDT');  // dt, zt2
194$start = new DateTime('2010-11-08 19:59:59');  // post, zt3
195examine_diff($end, $start, 'P-0Y0M1DT20H49M39S', 1);
196
197echo "test_time_fall_type3_post_type2_redodt: ";
198$end   = new DateTime('2010-11-07 01:12:33 EDT');  // redodt, zt2
199$start = new DateTime('2010-11-08 19:59:59');  // post, zt3
200examine_diff($end, $start, 'P-0Y0M1DT19H47M26S', 1);
201
202echo "test_time_fall_type3_post_type2_redost: ";
203$end   = new DateTime('2010-11-07 01:14:44 EST');  // redost, zt2
204$start = new DateTime('2010-11-08 19:59:59');  // post, zt3
205examine_diff($end, $start, 'P-0Y0M1DT18H45M15S', 1);
206
207echo "test_time_fall_type3_post_type2_st: ";
208$end   = new DateTime('2010-11-07 03:16:55 EST');  // st, zt2
209$start = new DateTime('2010-11-08 19:59:59');  // post, zt3
210examine_diff($end, $start, 'P-0Y0M1DT16H43M4S', 1);
211
212echo "test_time_fall_type3_post_type2_post: ";
213$end   = new DateTime('2010-11-08 19:59:59 EST');  // post, zt2
214$start = new DateTime('2010-11-08 18:57:55');  // sp post, zt3
215examine_diff($end, $start, 'P+0Y0M0DT1H2M4S', 0);
216
217echo "test_time_fall_type3_dtsec_type2_stsec: ";
218$end   = new DateTime('2010-11-07 01:00:00 EST');  // stsec, zt2
219$start = new DateTime('2010-11-07 01:59:59 EDT');  // dtsec, zt2
220$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
221examine_diff($end, $start, 'P+0Y0M0DT0H0M1S', 0);
222
223echo "test_time_fall_type3_stsec_type2_dtsec: ";
224$end   = new DateTime('2010-11-07 01:59:59 EDT');  // dtsec, zt2
225$start = new DateTime('2010-11-07 01:00:00 EST');  // stsec, zt2
226$start->setTimezone(new DateTimeZone('America/New_York'));  // zt2 -> zt3
227examine_diff($end, $start, 'P-0Y0M0DT0H0M1S', 0);
228