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 3 13 * 14 * + prev: the day before the transition day 2010-11-06 18:38:28 15 * + dt: daylight time on transition day 2010-11-07 00:10:20 16 * + redodt: daylight time in the redo period 2010-11-07 01:12:33 EDT, + TZ 17 * + redost: standard time in the redo period 2010-11-07 01:14:44 EST, + TZ 18 * + st: standard time on the transition day 2010-11-07 03:16:55 19 * + post: the day after the transition day 2010-11-08 19:59:59 20 * + dtsec: daylight time 1 sec before change 2010-11-07 01:59:59 EDT, + TZ 21 * + stsec: standard time first second 2010-11-07 01:00:00 EST, + TZ 22 */ 23echo "test_time_fall_type3_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'); // sp prev, zt3 26examine_diff($end, $start, 'P+0Y1M2DT16H19M40S', 33); 27 28echo "test_time_fall_type3_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'); // prev, zt3 31examine_diff($end, $start, 'P+0Y0M0DT5H31M52S', 0); 32 33echo "test_time_fall_type3_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'); // prev, zt3 37examine_diff($end, $start, 'P+0Y0M0DT6H34M5S', 0); 38 39echo "test_time_fall_type3_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'); // prev, zt3 43examine_diff($end, $start, 'P+0Y0M0DT7H36M16S', 0); 44 45echo "test_time_fall_type3_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'); // prev, zt3 48examine_diff($end, $start, 'P+0Y0M0DT9H38M27S', 0); 49 50echo "test_time_fall_type3_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'); // prev, zt3 53examine_diff($end, $start, 'P+0Y0M2DT1H21M31S', 2); 54 55echo "test_time_fall_type3_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'); // dt, zt3 58examine_diff($end, $start, 'P-0Y0M0DT5H31M52S', 0); 59 60echo "test_time_fall_type3_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'); // dt, zt3 63examine_diff($end, $start, 'P+0Y0M0DT0H5M15S', 0); 64 65echo "test_time_fall_type3_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'); // dt, zt3 69examine_diff($end, $start, 'P+0Y0M0DT1H2M13S', 0); 70 71echo "test_time_fall_type3_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'); // dt, zt3 75examine_diff($end, $start, 'P+0Y0M0DT2H4M24S', 0); 76 77echo "test_time_fall_type3_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'); // dt, zt3 80examine_diff($end, $start, 'P+0Y0M0DT4H6M35S', 0); 81 82echo "test_time_fall_type3_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'); // dt, zt3 85examine_diff($end, $start, 'P+0Y0M1DT20H49M39S', 1); 86 87echo "test_time_fall_type3_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 90$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 91examine_diff($end, $start, 'P-0Y0M0DT6H34M5S', 0); 92 93echo "test_time_fall_type3_redodt_type3_dt: "; 94$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 95$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 96$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 97examine_diff($end, $start, 'P-0Y0M0DT1H2M13S', 0); 98 99echo "test_time_fall_type3_redodt_type3_redodt: "; 100$end = new DateTime('2010-11-07 01:15:35 EDT'); // sp redodt, zt2 101$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 102$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 103$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 104examine_diff($end, $start, 'P+0Y0M0DT0H3M2S', 0); 105 106echo "test_time_fall_type3_redodt_type3_redost: "; 107$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 108$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 109$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 110$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 111examine_diff($end, $start, 'P+0Y0M0DT1H2M11S', 0); 112 113echo "test_time_fall_type3_redodt_type3_st: "; 114$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 115$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 116$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 117examine_diff($end, $start, 'P+0Y0M0DT3H4M22S', 0); 118 119echo "test_time_fall_type3_redodt_type3_post: "; 120$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 121$start = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 122$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 123examine_diff($end, $start, 'P+0Y0M1DT19H47M26S', 1); 124 125echo "test_time_fall_type3_redost_type3_prev: "; 126$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 127$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 128$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 129examine_diff($end, $start, 'P-0Y0M0DT7H36M16S', 0); 130 131echo "test_time_fall_type3_redost_type3_dt: "; 132$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 133$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 134$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 135examine_diff($end, $start, 'P-0Y0M0DT2H4M24S', 0); 136 137echo "test_time_fall_type3_redost_type3_redodt: "; 138$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 139$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 140$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 141$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 142examine_diff($end, $start, 'P-0Y0M0DT1H2M11S', 0); 143 144echo "test_time_fall_type3_redost_type3_redost: "; 145$end = new DateTime('2010-11-07 01:16:54 EST'); // sp redodt, zt2 146$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 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+0Y0M0DT0H2M10S', 0); 150 151echo "test_time_fall_type3_redost_type3_st: "; 152$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 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+0Y0M0DT2H2M11S', 0); 156 157echo "test_time_fall_type3_redost_type3_post: "; 158$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 159$start = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 160$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 161examine_diff($end, $start, 'P+0Y0M1DT18H45M15S', 1); 162 163echo "test_time_fall_type3_st_type3_prev: "; 164$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 165$start = new DateTime('2010-11-07 03:16:55'); // st, zt3 166examine_diff($end, $start, 'P-0Y0M0DT9H38M27S', 0); 167 168echo "test_time_fall_type3_st_type3_dt: "; 169$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 170$start = new DateTime('2010-11-07 03:16:55'); // st, zt3 171examine_diff($end, $start, 'P-0Y0M0DT4H6M35S', 0); 172 173echo "test_time_fall_type3_st_type3_redodt: "; 174$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 175$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 176$start = new DateTime('2010-11-07 03:16:55'); // st, zt3 177examine_diff($end, $start, 'P-0Y0M0DT3H4M22S', 0); 178 179echo "test_time_fall_type3_st_type3_redost: "; 180$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 181$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 182$start = new DateTime('2010-11-07 03:16:55'); // st, zt3 183examine_diff($end, $start, 'P-0Y0M0DT2H2M11S', 0); 184 185echo "test_time_fall_type3_st_type3_st: "; 186$end = new DateTime('2010-11-07 05:19:56'); // sp st, zt3 187$start = new DateTime('2010-11-07 03:16:55'); // st, zt3 188examine_diff($end, $start, 'P+0Y0M0DT2H3M1S', 0); 189 190echo "test_time_fall_type3_st_type3_post: "; 191$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 192$start = new DateTime('2010-11-07 03:16:55'); // st, zt3 193examine_diff($end, $start, 'P+0Y0M1DT16H43M4S', 1); 194 195echo "test_time_fall_type3_post_type3_prev: "; 196$end = new DateTime('2010-11-06 18:38:28'); // prev, zt3 197$start = new DateTime('2010-11-08 19:59:59'); // post, zt3 198examine_diff($end, $start, 'P-0Y0M2DT1H21M31S', 2); 199 200echo "test_time_fall_type3_post_type3_dt: "; 201$end = new DateTime('2010-11-07 00:10:20'); // dt, zt3 202$start = new DateTime('2010-11-08 19:59:59'); // post, zt3 203examine_diff($end, $start, 'P-0Y0M1DT20H49M39S', 1); 204 205echo "test_time_fall_type3_post_type3_redodt: "; 206$end = new DateTime('2010-11-07 01:12:33 EDT'); // redodt, zt2 207$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 208$start = new DateTime('2010-11-08 19:59:59'); // post, zt3 209examine_diff($end, $start, 'P-0Y0M1DT19H47M26S', 1); 210 211echo "test_time_fall_type3_post_type3_redost: "; 212$end = new DateTime('2010-11-07 01:14:44 EST'); // redost, zt2 213$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 214$start = new DateTime('2010-11-08 19:59:59'); // post, zt3 215examine_diff($end, $start, 'P-0Y0M1DT18H45M15S', 1); 216 217echo "test_time_fall_type3_post_type3_st: "; 218$end = new DateTime('2010-11-07 03:16:55'); // st, zt3 219$start = new DateTime('2010-11-08 19:59:59'); // post, zt3 220examine_diff($end, $start, 'P-0Y0M1DT16H43M4S', 1); 221 222echo "test_time_fall_type3_post_type3_post: "; 223$end = new DateTime('2010-11-08 19:59:59'); // post, zt3 224$start = new DateTime('2010-11-08 18:57:55'); // sp post, zt3 225examine_diff($end, $start, 'P+0Y0M0DT1H2M4S', 0); 226 227echo "test_time_fall_type3_dtsec_type3_stsec: "; 228$end = new DateTime('2010-11-07 01:00:00 EST'); // stsec, zt2 229$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 230$start = new DateTime('2010-11-07 01:59:59 EDT'); // dtsec, zt2 231$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 232examine_diff($end, $start, 'P+0Y0M0DT0H0M1S', 0); 233 234echo "test_time_fall_type3_stsec_type3_dtsec: "; 235$end = new DateTime('2010-11-07 01:59:59 EDT'); // dtsec, zt2 236$end->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 237$start = new DateTime('2010-11-07 01:00:00 EST'); // stsec, zt2 238$start->setTimezone(new DateTimeZone('America/New_York')); // zt2 -> zt3 239examine_diff($end, $start, 'P-0Y0M0DT0H0M1S', 0); 240