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 2 to Zone Type 3 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_type2_prev_type3_prev: "; 24$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 25$start = new DateTime('2010-10-04 02:18:48 EDT'); // sp prev, zt2 26examine_diff($end, $start, 'P+0Y1M2DT16H19M40S', 33); 27 28echo "test_time_fall_type2_prev_type3_dt: "; 29$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 30$start = new DateTime('2010-11-06 18:38:28 EDT'); // prev, zt2 31examine_diff($end, $start, 'P+0Y0M0DT5H31M52S', 0); 32 33echo "test_time_fall_type2_prev_type3_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 EDT'); // prev, zt2 37examine_diff($end, $start, 'P+0Y0M0DT6H34M5S', 0); 38 39echo "test_time_fall_type2_prev_type3_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 EDT'); // prev, zt2 43examine_diff($end, $start, 'P+0Y0M0DT7H36M16S', 0); 44 45echo "test_time_fall_type2_prev_type3_st: "; 46$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 47$start = new DateTime('2010-11-06 18:38:28 EDT'); // prev, zt2 48examine_diff($end, $start, 'P+0Y0M0DT9H38M27S', 0); 49 50echo "test_time_fall_type2_prev_type3_post: "; 51$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 52$start = new DateTime('2010-11-06 18:38:28 EDT'); // prev, zt2 53examine_diff($end, $start, 'P+0Y0M2DT1H21M31S', 2); 54 55echo "test_time_fall_type2_dt_type3_prev: "; 56$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 57$start = new DateTime('2010-11-07 00:10:20 EDT'); // dt, zt2 58examine_diff($end, $start, 'P-0Y0M0DT5H31M52S', 0); 59 60echo "test_time_fall_type2_dt_type3_dt: "; 61$end = new DateTime('2010-11-07 00:15:35'); // sp dt, zt3 62$start = new DateTime('2010-11-07 00:10:20 EDT'); // dt, zt2 63examine_diff($end, $start, 'P+0Y0M0DT0H5M15S', 0); 64 65echo "test_time_fall_type2_dt_type3_redodt: "; 66$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 67$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 68$start = new DateTime('2010-11-07 00:10:20 EDT'); // dt, zt2 69examine_diff($end, $start, 'P+0Y0M0DT1H2M13S', 0); 70 71echo "test_time_fall_type2_dt_type3_redost: "; 72$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 73$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 74$start = new DateTime('2010-11-07 00:10:20 EDT'); // dt, zt2 75examine_diff($end, $start, 'P+0Y0M0DT2H4M24S', 0); 76 77echo "test_time_fall_type2_dt_type3_st: "; 78$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 79$start = new DateTime('2010-11-07 00:10:20 EDT'); // dt, zt2 80examine_diff($end, $start, 'P+0Y0M0DT4H6M35S', 0); 81 82echo "test_time_fall_type2_dt_type3_post: "; 83$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 84$start = new DateTime('2010-11-07 00:10:20 EDT'); // dt, zt2 85examine_diff($end, $start, 'P+0Y0M1DT20H49M39S', 1); 86 87echo "test_time_fall_type2_redodt_type3_prev: "; 88$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 89$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 90examine_diff($end, $start, 'P-0Y0M0DT6H34M5S', 0); 91 92echo "test_time_fall_type2_redodt_type3_dt: "; 93$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 94$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 95examine_diff($end, $start, 'P-0Y0M0DT1H2M13S', 0); 96 97echo "test_time_fall_type2_redodt_type3_redodt: "; 98$end = new DateTime('2010-11-07 01:15:35 EDT'); // sp redodt, zt2 99$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 100$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 101examine_diff($end, $start, 'P+0Y0M0DT0H3M2S', 0); 102 103echo "test_time_fall_type2_redodt_type3_redost: "; 104$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 105$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 106$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 107examine_diff($end, $start, 'P+0Y0M0DT1H2M11S', 0); 108 109echo "test_time_fall_type2_redodt_type3_st: "; 110$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 111$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 112examine_diff($end, $start, 'P+0Y0M0DT3H4M22S', 0); 113 114echo "test_time_fall_type2_redodt_type3_post: "; 115$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 116$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 117examine_diff($end, $start, 'P+0Y0M1DT19H47M26S', 1); 118 119echo "test_time_fall_type2_redost_type3_prev: "; 120$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 121$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 122examine_diff($end, $start, 'P-0Y0M0DT7H36M16S', 0); 123 124echo "test_time_fall_type2_redost_type3_dt: "; 125$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 126$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 127examine_diff($end, $start, 'P-0Y0M0DT2H4M24S', 0); 128 129echo "test_time_fall_type2_redost_type3_redodt: "; 130$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 131$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 132$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 133examine_diff($end, $start, 'P-0Y0M0DT1H2M11S', 0); 134 135echo "test_time_fall_type2_redost_type3_redost: "; 136$end = new DateTime('2010-11-07 01:16:54 EST'); // sp redodt, zt2 137$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 138$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 139examine_diff($end, $start, 'P+0Y0M0DT0H2M10S', 0); 140 141echo "test_time_fall_type2_redost_type3_st: "; 142$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 143$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 144examine_diff($end, $start, 'P+0Y0M0DT2H2M11S', 0); 145 146echo "test_time_fall_type2_redost_type3_post: "; 147$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 148$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 149examine_diff($end, $start, 'P+0Y0M1DT18H45M15S', 1); 150 151echo "test_time_fall_type2_st_type3_prev: "; 152$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 153$start = new DateTime('2010-11-07 03:16:55 EST'); // st, zt2 154examine_diff($end, $start, 'P-0Y0M0DT9H38M27S', 0); 155 156echo "test_time_fall_type2_st_type3_dt: "; 157$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 158$start = new DateTime('2010-11-07 03:16:55 EST'); // st, zt2 159examine_diff($end, $start, 'P-0Y0M0DT4H6M35S', 0); 160 161echo "test_time_fall_type2_st_type3_redodt: "; 162$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 163$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 164$start = new DateTime('2010-11-07 03:16:55 EST'); // st, zt2 165examine_diff($end, $start, 'P-0Y0M0DT3H4M22S', 0); 166 167echo "test_time_fall_type2_st_type3_redost: "; 168$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 169$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 170$start = new DateTime('2010-11-07 03:16:55 EST'); // st, zt2 171examine_diff($end, $start, 'P-0Y0M0DT2H2M11S', 0); 172 173echo "test_time_fall_type2_st_type3_st: "; 174$end = new DateTime('2010-11-07 05:19:56'); // sp st, zt3 175$start = new DateTime('2010-11-07 03:16:55 EST'); // st, zt2 176examine_diff($end, $start, 'P+0Y0M0DT2H3M1S', 0); 177 178echo "test_time_fall_type2_st_type3_post: "; 179$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 180$start = new DateTime('2010-11-07 03:16:55 EST'); // st, zt2 181examine_diff($end, $start, 'P+0Y0M1DT16H43M4S', 1); 182 183echo "test_time_fall_type2_post_type3_prev: "; 184$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 185$start = new DateTime('2010-11-08 19:59:59 EST'); // post, zt2 186examine_diff($end, $start, 'P-0Y0M2DT1H21M31S', 2); 187 188echo "test_time_fall_type2_post_type3_dt: "; 189$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 190$start = new DateTime('2010-11-08 19:59:59 EST'); // post, zt2 191examine_diff($end, $start, 'P-0Y0M1DT20H49M39S', 1); 192 193echo "test_time_fall_type2_post_type3_redodt: "; 194$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 195$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 196$start = new DateTime('2010-11-08 19:59:59 EST'); // post, zt2 197examine_diff($end, $start, 'P-0Y0M1DT19H47M26S', 1); 198 199echo "test_time_fall_type2_post_type3_redost: "; 200$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 201$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 202$start = new DateTime('2010-11-08 19:59:59 EST'); // post, zt2 203examine_diff($end, $start, 'P-0Y0M1DT18H45M15S', 1); 204 205echo "test_time_fall_type2_post_type3_st: "; 206$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 207$start = new DateTime('2010-11-08 19:59:59 EST'); // post, zt2 208examine_diff($end, $start, 'P-0Y0M1DT16H43M4S', 1); 209 210echo "test_time_fall_type2_post_type3_post: "; 211$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 212$start = new DateTime('2010-11-08 18:57:55 EST'); // sp post, zt2 213examine_diff($end, $start, 'P+0Y0M0DT1H2M4S', 0); 214 215echo "test_time_fall_type2_dtsec_type3_stsec: "; 216$end = new DateTime('2010-11-07 01:00:00 EST'); // stsec, zt2 217$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 218$start = new DateTime('2010-11-07 01:59:59 EDT'); // dtsec, zt2 219examine_diff($end, $start, 'P+0Y0M0DT0H0M1S', 0); 220 221echo "test_time_fall_type2_stsec_type3_dtsec: "; 222$end = new DateTime('2010-11-07 01:59:59 EDT'); // dtsec, zt2 223$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 224$start = new DateTime('2010-11-07 01:00:00 EST'); // stsec, zt2 225examine_diff($end, $start, 'P-0Y0M0DT0H0M1S', 0); 226