summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2013-11-28 14:26:01 +0000
committerDerick Rethans <github@derickrethans.nl>2013-11-28 14:26:01 +0000
commitc1eb219aad2e23db5db27d887b93b06c1537fec9 (patch)
tree3f379c7d347a999f2c8f6067a7f652151d01914d
parentfb0c2cf2245838cba1bd9318925d67a127c7b085 (diff)
parentaab0b2ce3b8641848e7e92b9e5c4db044004133d (diff)
downloadphp-git-c1eb219aad2e23db5db27d887b93b06c1537fec9.tar.gz
Merge branch 'date-time-dst-rfc' into PHP-5.4
This is a partial resolve of some DST issues, plenty of things to do, but as this *does* fix a few issues it's worth merging it already.
-rw-r--r--ext/date/lib/interval.c103
-rw-r--r--ext/date/lib/timelib.h2
-rw-r--r--ext/date/lib/unixtime2tm.c9
-rw-r--r--ext/date/php_date.c50
-rw-r--r--ext/date/tests/forward-transition-construction.phpt27
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt96
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt48
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt56
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt92
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt58
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt58
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt67
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt399
13 files changed, 615 insertions, 450 deletions
diff --git a/ext/date/lib/interval.c b/ext/date/lib/interval.c
index 96867ba2b7..dce62f3a28 100644
--- a/ext/date/lib/interval.c
+++ b/ext/date/lib/interval.c
@@ -25,7 +25,7 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
{
timelib_rel_time *rt;
timelib_time *swp;
- timelib_sll dst_h_corr = 0, dst_m_corr = 0;
+ timelib_sll dst_corr = 0 ,dst_h_corr = 0, dst_m_corr = 0;
timelib_time one_backup, two_backup;
rt = timelib_rel_time_ctor();
@@ -43,8 +43,9 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
&& (strcmp(one->tz_info->name, two->tz_info->name) == 0)
&& (one->z != two->z))
{
- dst_h_corr = (two->z - one->z) / 3600;
- dst_m_corr = ((two->z - one->z) % 3600) / 60;
+ dst_corr = two->z - one->z;
+ dst_h_corr = dst_corr / 3600;
+ dst_m_corr = (dst_corr % 3600) / 60;
}
/* Save old TZ info */
@@ -57,16 +58,108 @@ timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two)
rt->y = two->y - one->y;
rt->m = two->m - one->m;
rt->d = two->d - one->d;
- rt->h = two->h - one->h + dst_h_corr;
- rt->i = two->i - one->i + dst_m_corr;
+ rt->h = two->h - one->h;
+ rt->i = two->i - one->i;
rt->s = two->s - one->s;
+ if (one_backup.dst == 0 && two_backup.dst == 1 && two->sse >= one->sse + 86400 - dst_corr) {
+ rt->h += dst_h_corr;
+ rt->i += dst_m_corr;
+ }
+
rt->days = abs(floor((one->sse - two->sse - (dst_h_corr * 3600) - (dst_m_corr * 60)) / 86400));
timelib_do_rel_normalize(rt->invert ? one : two, rt);
+ /* We need to do this after normalisation otherwise we can't get "24H" */
+ if (one_backup.dst == 1 && two_backup.dst == 0 && two->sse >= one->sse + 86400) {
+ if (two->sse < one->sse + 86400 - dst_corr) {
+ rt->d--;
+ rt->h = 24;
+ } else {
+ rt->h += dst_h_corr;
+ rt->i += dst_m_corr;
+ }
+ }
+
/* Restore old TZ info */
memcpy(one, &one_backup, sizeof(one_backup));
memcpy(two, &two_backup, sizeof(two_backup));
return rt;
}
+
+timelib_time *timelib_add(timelib_time *old_time, timelib_rel_time *interval)
+{
+ int bias = 1;
+ timelib_time *t = timelib_time_clone(old_time);
+
+ if (interval->have_weekday_relative || interval->have_special_relative) {
+ memcpy(&t->relative, interval, sizeof(struct timelib_rel_time));
+ } else {
+ if (interval->invert) {
+ bias = -1;
+ }
+ memset(&t->relative, 0, sizeof(struct timelib_rel_time));
+ t->relative.y = interval->y * bias;
+ t->relative.m = interval->m * bias;
+ t->relative.d = interval->d * bias;
+ t->relative.h = interval->h * bias;
+ t->relative.i = interval->i * bias;
+ t->relative.s = interval->s * bias;
+ }
+ t->have_relative = 1;
+ t->sse_uptodate = 0;
+
+ timelib_update_ts(t, NULL);
+
+// printf("%lld %lld %d\n", old_time->dst, t->dst, (t->sse - old_time->sse));
+ /* Adjust for backwards DST changeover */
+ if (old_time->dst == 1 && t->dst == 0 && !interval->y && !interval->m && !interval->d) {
+ t->sse -= old_time->z;
+ t->sse += t->z;
+ }
+
+ timelib_update_from_sse(t);
+ t->have_relative = 0;
+
+ return t;
+}
+
+timelib_time *timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
+{
+ int bias = 1;
+ timelib_time *t = timelib_time_clone(old_time);
+
+ if (interval->invert) {
+ bias = -1;
+ }
+
+ memset(&t->relative, 0, sizeof(struct timelib_rel_time));
+ t->relative.y = 0 - (interval->y * bias);
+ t->relative.m = 0 - (interval->m * bias);
+ t->relative.d = 0 - (interval->d * bias);
+ t->relative.h = 0 - (interval->h * bias);
+ t->relative.i = 0 - (interval->i * bias);
+ t->relative.s = 0 - (interval->s * bias);
+ t->have_relative = 1;
+ t->sse_uptodate = 0;
+
+ timelib_update_ts(t, NULL);
+
+ /* Adjust for backwards DST changeover */
+ if (old_time->dst == 1 && t->dst == 0 && !interval->y && !interval->m && !interval->d) {
+ t->sse -= old_time->z;
+ t->sse += t->z;
+ }
+ /* Adjust for forwards DST changeover */
+ if (old_time->dst == 0 && t->dst == 1 && !interval->y && !interval->m && !interval->d ) {
+ t->sse -= old_time->z;
+ t->sse += t->z;
+ }
+
+ timelib_update_from_sse(t);
+
+ t->have_relative = 0;
+
+ return t;
+}
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 478dec32d0..2acb765e63 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -136,5 +136,7 @@ int timelib_astro_rise_set_altitude(timelib_time *time, double lon, double lat,
/* from interval.c */
timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two);
+timelib_time *timelib_add(timelib_time *t, timelib_rel_time *interval);
+timelib_time *timelib_sub(timelib_time *t, timelib_rel_time *interval);
#endif
diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c
index c177feebb1..194b3b2116 100644
--- a/ext/date/lib/unixtime2tm.c
+++ b/ext/date/lib/unixtime2tm.c
@@ -137,19 +137,16 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts)
void timelib_update_from_sse(timelib_time *tm)
{
timelib_sll sse;
+ int z = tm->z;
+ signed int dst = tm->dst;
sse = tm->sse;
switch (tm->zone_type) {
case TIMELIB_ZONETYPE_ABBR:
case TIMELIB_ZONETYPE_OFFSET: {
- int z = tm->z;
- signed int dst = tm->dst;
-
timelib_unixtime2gmt(tm, tm->sse - (tm->z * 60) + (tm->dst * 3600));
- tm->z = z;
- tm->dst = dst;
goto cleanup;
}
@@ -171,6 +168,8 @@ cleanup:
tm->sse = sse;
tm->is_localtime = 1;
tm->have_zone = 1;
+ tm->z = z;
+ tm->dst = dst;
}
void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index b7da07c7bd..2bb555a68b 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2487,6 +2487,7 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
timelib_fill_holes(dateobj->time, now, TIMELIB_NO_CLONE);
timelib_update_ts(dateobj->time, tzi);
+ timelib_update_from_sse(dateobj->time);
dateobj->time->have_relative = 0;
@@ -2888,7 +2889,7 @@ PHP_FUNCTION(date_add)
zval *object, *interval;
php_date_obj *dateobj;
php_interval_obj *intobj;
- int bias = 1;
+ timelib_time *new_time;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) {
RETURN_FALSE;
@@ -2898,27 +2899,9 @@ PHP_FUNCTION(date_add)
intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC);
DATE_CHECK_INITIALIZED(intobj->initialized, DateInterval);
-
- if (intobj->diff->have_weekday_relative || intobj->diff->have_special_relative) {
- memcpy(&dateobj->time->relative, intobj->diff, sizeof(struct timelib_rel_time));
- } else {
- if (intobj->diff->invert) {
- bias = -1;
- }
- memset(&dateobj->time->relative, 0, sizeof(struct timelib_rel_time));
- dateobj->time->relative.y = intobj->diff->y * bias;
- dateobj->time->relative.m = intobj->diff->m * bias;
- dateobj->time->relative.d = intobj->diff->d * bias;
- dateobj->time->relative.h = intobj->diff->h * bias;
- dateobj->time->relative.i = intobj->diff->i * bias;
- dateobj->time->relative.s = intobj->diff->s * bias;
- }
- dateobj->time->have_relative = 1;
- dateobj->time->sse_uptodate = 0;
-
- timelib_update_ts(dateobj->time, NULL);
- timelib_update_from_sse(dateobj->time);
- dateobj->time->have_relative = 0;
+ new_time = timelib_add(dateobj->time, intobj->diff);
+ timelib_time_dtor(dateobj->time);
+ dateobj->time = new_time;
RETURN_ZVAL(object, 1, 0);
}
@@ -2932,7 +2915,7 @@ PHP_FUNCTION(date_sub)
zval *object, *interval;
php_date_obj *dateobj;
php_interval_obj *intobj;
- int bias = 1;
+ timelib_time *new_time;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) {
RETURN_FALSE;
@@ -2947,24 +2930,9 @@ PHP_FUNCTION(date_sub)
return;
}
- if (intobj->diff->invert) {
- bias = -1;
- }
-
- memset(&dateobj->time->relative, 0, sizeof(struct timelib_rel_time));
- dateobj->time->relative.y = 0 - (intobj->diff->y * bias);
- dateobj->time->relative.m = 0 - (intobj->diff->m * bias);
- dateobj->time->relative.d = 0 - (intobj->diff->d * bias);
- dateobj->time->relative.h = 0 - (intobj->diff->h * bias);
- dateobj->time->relative.i = 0 - (intobj->diff->i * bias);
- dateobj->time->relative.s = 0 - (intobj->diff->s * bias);
- dateobj->time->have_relative = 1;
- dateobj->time->sse_uptodate = 0;
-
- timelib_update_ts(dateobj->time, NULL);
- timelib_update_from_sse(dateobj->time);
-
- dateobj->time->have_relative = 0;
+ new_time = timelib_sub(dateobj->time, intobj->diff);
+ timelib_time_dtor(dateobj->time);
+ dateobj->time = new_time;
RETURN_ZVAL(object, 1, 0);
}
diff --git a/ext/date/tests/forward-transition-construction.phpt b/ext/date/tests/forward-transition-construction.phpt
new file mode 100644
index 0000000000..8f195a51bd
--- /dev/null
+++ b/ext/date/tests/forward-transition-construction.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test for Date/Time construction during a forward DST transition
+--FILE--
+<?php
+date_default_timezone_set('America/New_York');
+
+$date = new DateTime('2010-03-14 01:30:00');
+echo $date->format('Y-m-d H:i:s T/e - U') . "\n";
+
+$date = new DateTime('2010-03-14 02:00:00');
+echo $date->format('Y-m-d H:i:s T/e - U') . "\n";
+
+$date = new DateTime('2010-03-14 02:30:00');
+echo $date->format('Y-m-d H:i:s T/e - U') . "\n";
+
+$date = new DateTime('2010-03-14 03:00:00');
+echo $date->format('Y-m-d H:i:s T/e - U') . "\n";
+
+$date = new DateTime('2010-03-14 03:30:00');
+echo $date->format('Y-m-d H:i:s T/e - U') . "\n";
+?>
+--EXPECT--
+2010-03-14 01:30:00 EST/America/New_York - 1268548200
+2010-03-14 03:00:00 EDT/America/New_York - 1268550000
+2010-03-14 03:30:00 EDT/America/New_York - 1268551800
+2010-03-14 03:00:00 EDT/America/New_York - 1268550000
+2010-03-14 03:30:00 EDT/America/New_York - 1268551800
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt
new file mode 100644
index 0000000000..fdbe96d7d0
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-ba.phpt
@@ -0,0 +1,96 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, ba)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Backward Transitions, add().
+ */
+
+$start = new DateTime('2010-11-07 01:59:59');
+$interval_spec = 'PT1S';
+$interval = new DateInterval($interval_spec);
+echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 04:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 04:30:00');
+$interval_spec = 'PT24H';
+$interval = new DateInterval($interval_spec);
+echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 04:30:00');
+$interval_spec = 'PT23H';
+$interval = new DateInterval($interval_spec);
+echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 04:30:00');
+$interval_spec = 'PT22H';
+$interval = new DateInterval($interval_spec);
+echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 04:30:00');
+$interval_spec = 'PT21H';
+$interval = new DateInterval($interval_spec);
+echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 01:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 01:30:00');
+$interval_spec = 'P1DT1H';
+$interval = new DateInterval($interval_spec);
+echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 04:30:00');
+$interval_spec = 'PT25H';
+$interval = new DateInterval($interval_spec);
+echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 03:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-11-06 02:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+echo "\n";
+
+?>
+--EXPECT--
+ba1 2010-11-07 01:59:59 EDT America/New_York + PT1S = 2010-11-07 01:00:00 EST America/New_York
+ba2 2010-11-06 04:30:00 EDT America/New_York + P1D = 2010-11-07 04:30:00 EST America/New_York
+ba3 2010-11-06 04:30:00 EDT America/New_York + PT24H = 2010-11-07 03:30:00 EST America/New_York
+ba4 2010-11-06 04:30:00 EDT America/New_York + PT23H = 2010-11-07 02:30:00 EST America/New_York
+ba5 2010-11-06 04:30:00 EDT America/New_York + PT22H = 2010-11-07 01:30:00 EST America/New_York
+ba6 2010-11-06 04:30:00 EDT America/New_York + PT21H = 2010-11-07 01:30:00 EDT America/New_York
+ba7 2010-11-06 01:30:00 EDT America/New_York + P1D = 2010-11-07 01:30:00 EDT America/New_York
+ba8 2010-11-06 01:30:00 EDT America/New_York + P1DT1H = 2010-11-07 02:30:00 EST America/New_York
+ba9 2010-11-06 04:30:00 EDT America/New_York + PT25H = 2010-11-07 04:30:00 EST America/New_York
+ba10 2010-11-06 03:30:00 EDT America/New_York + P1D = 2010-11-07 03:30:00 EST America/New_York
+ba11 2010-11-06 02:30:00 EDT America/New_York + P1D = 2010-11-07 02:30:00 EST America/New_York
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt
new file mode 100644
index 0000000000..8249599931
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd1.phpt
@@ -0,0 +1,48 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, bd1)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Backward Transitions, diff().
+ */
+
+$end = new DateTime('2010-11-07 05:30:00');
+$start = new DateTime('2010-11-06 04:30:00');
+echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-11-07 04:30:00');
+$start = new DateTime('2010-11-06 04:30:00');
+echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-11-07 03:30:00');
+$start = new DateTime('2010-11-06 04:30:00');
+echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-11-07 02:30:00');
+$start = new DateTime('2010-11-06 04:30:00');
+echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00');
+$start = new DateTime('2010-11-06 01:30:00');
+echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+echo "\n";
+?>
+--EXPECT--
+bd1 2010-11-07 05:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P1DT1H
+bd2 2010-11-07 04:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P1DT0H
+bd3 2010-11-07 03:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT24H
+bd4 2010-11-07 02:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT23H
+bd7 2010-11-07 01:30:00 EDT America/New_York - 2010-11-06 01:30:00 EDT America/New_York = P1DT0H
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt
new file mode 100644
index 0000000000..fe2e79b3b9
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bd2.phpt
@@ -0,0 +1,56 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, bd2)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--XFAIL--
+Still not quite right
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * For backward transitions, must create objects with zone type 2
+ * where specifying Daylight or Standard time is required
+ * then converting them to zone type 3.
+ */
+
+$tz = new DateTimeZone('America/New_York');
+
+/*
+ * Backward Transitions, diff().
+ */
+
+$end = new DateTime('2010-11-07 05:30:00');
+$end->setTimeZone($tz);
+$start = new DateTime('2010-11-06 04:30:59');
+echo 'bd0 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format('P%dDT%hH%iM%sS') . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00 EST');
+$end->setTimeZone($tz);
+$start = new DateTime('2010-11-06 04:30:00');
+echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00 EDT');
+$end->setTimeZone($tz);
+$start = new DateTime('2010-11-06 04:30:00');
+echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00 EST');
+$end->setTimeZone($tz);
+$start = new DateTime('2010-11-06 01:30:00');
+echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+echo "\n";
+?>
+--EXPECT--
+bd0 2010-11-07 01:00:00 EST America/New_York - 2010-11-07 01:59:59 EDT America/New_York = PT0H0M1S
+bd5 2010-11-07 01:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT22H
+bd6 2010-11-07 01:30:00 EDT America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT21H
+bd8 2010-11-07 01:30:00 EST America/New_York - 2010-11-06 01:30:00 EDT America/New_York = P1DT1H
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt
new file mode 100644
index 0000000000..138c68f3a9
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-bs.phpt
@@ -0,0 +1,92 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, bs)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$tz = new DateTimeZone('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Backward Transitions, sub().
+ */
+
+$end = new DateTime('2010-11-07 01:00:00 EST');
+$end->setTimeZone($tz);
+$interval_spec = 'PT1S';
+$interval = new DateInterval($interval_spec);
+echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 04:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 03:30:00');
+$interval_spec = 'PT24H';
+$interval = new DateInterval($interval_spec);
+echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 02:30:00');
+$interval_spec = 'PT23H';
+$interval = new DateInterval($interval_spec);
+echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00 EST');
+$end->setTimeZone($tz);
+$interval_spec = 'PT22H';
+$interval = new DateInterval($interval_spec);
+echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00 EDT');
+$end->setTimeZone($tz);
+$interval_spec = 'PT21H';
+$interval = new DateInterval($interval_spec);
+echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 01:30:00 EST');
+$end->setTimeZone($tz);
+$interval_spec = 'P1DT1H';
+$interval = new DateInterval($interval_spec);
+echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 03:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-11-07 02:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+?>
+--EXPECT--
+bs1 2010-11-07 01:00:00 EST America/New_York - PT1S = 2010-11-07 01:59:59 EDT America/New_York
+bs2 2010-11-07 04:30:00 EST America/New_York - P1D = 2010-11-06 04:30:00 EDT America/New_York
+bs3 2010-11-07 03:30:00 EST America/New_York - PT24H = 2010-11-06 04:30:00 EDT America/New_York
+bs4 2010-11-07 02:30:00 EST America/New_York - PT23H = 2010-11-06 04:30:00 EDT America/New_York
+bs5 2010-11-07 01:30:00 EST America/New_York - PT22H = 2010-11-06 04:30:00 EDT America/New_York
+bs6 2010-11-07 01:30:00 EDT America/New_York - PT21H = 2010-11-06 04:30:00 EDT America/New_York
+bs7 2010-11-07 01:30:00 EDT America/New_York - P1D = 2010-11-06 01:30:00 EDT America/New_York
+bs8 2010-11-07 01:30:00 EST America/New_York - P1DT1H = 2010-11-06 00:30:00 EDT America/New_York
+bs9 2010-11-07 03:30:00 EST America/New_York - P1D = 2010-11-06 03:30:00 EDT America/New_York
+bs10 2010-11-07 02:30:00 EST America/New_York - P1D = 2010-11-06 02:30:00 EDT America/New_York
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt
new file mode 100644
index 0000000000..9fa493f578
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fa.phpt
@@ -0,0 +1,58 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, fa)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Forward Transitions, add().
+ */
+
+$start = new DateTime('2010-03-14 01:59:59');
+$interval_spec = 'PT1S';
+$interval = new DateInterval($interval_spec);
+echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-03-13 04:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-03-13 04:30:00');
+$interval_spec = 'PT22H';
+$interval = new DateInterval($interval_spec);
+echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-03-13 04:30:00');
+$interval_spec = 'PT21H';
+$interval = new DateInterval($interval_spec);
+echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-03-13 01:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+
+$start = new DateTime('2010-03-13 02:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = "
+ . $start->add($interval)->format($date_format) . "\n";
+?>
+--EXPECT--
+fa1 2010-03-14 01:59:59 EST America/New_York + PT1S = 2010-03-14 03:00:00 EDT America/New_York
+fa2 2010-03-13 04:30:00 EST America/New_York + P1D = 2010-03-14 04:30:00 EDT America/New_York
+fa3 2010-03-13 04:30:00 EST America/New_York + PT22H = 2010-03-14 03:30:00 EDT America/New_York
+fa4 2010-03-13 04:30:00 EST America/New_York + PT21H = 2010-03-14 01:30:00 EST America/New_York
+fa5 2010-03-13 01:30:00 EST America/New_York + P1D = 2010-03-14 01:30:00 EST America/New_York
+fa6 2010-03-13 02:30:00 EST America/New_York + P1D = 2010-03-14 03:30:00 EDT America/New_York
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt
new file mode 100644
index 0000000000..ae7060be0b
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fd.phpt
@@ -0,0 +1,58 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, fd)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Forward Transitions, diff().
+ */
+
+$end = new DateTime('2010-03-14 03:00:00');
+$start = new DateTime('2010-03-14 01:59:59');
+echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
+
+$end = new DateTime('2010-03-14 04:30:00');
+$start = new DateTime('2010-03-13 04:30:00');
+echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-03-14 03:30:00');
+$start = new DateTime('2010-03-13 04:30:00');
+echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-03-14 01:30:00');
+$start = new DateTime('2010-03-13 04:30:00');
+echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-03-14 01:30:00');
+$start = new DateTime('2010-03-13 01:30:00');
+echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-03-14 03:30:00');
+$start = new DateTime('2010-03-13 03:30:00');
+echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+
+$end = new DateTime('2010-03-14 03:30:00');
+$start = new DateTime('2010-03-13 02:30:00');
+echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
+ . ' = ' . $start->diff($end)->format($interval_format) . "\n";
+?>
+--EXPECT--
+fd1 2010-03-14 03:00:00 EDT America/New_York - 2010-03-14 01:59:59 EST America/New_York = PT0H0M1S
+fd2 2010-03-14 04:30:00 EDT America/New_York - 2010-03-13 04:30:00 EST America/New_York = P1DT0H
+fd3 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 04:30:00 EST America/New_York = P0DT22H
+fd4 2010-03-14 01:30:00 EST America/New_York - 2010-03-13 04:30:00 EST America/New_York = P0DT21H
+fd5 2010-03-14 01:30:00 EST America/New_York - 2010-03-13 01:30:00 EST America/New_York = P1DT0H
+fd6 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 03:30:00 EST America/New_York = P1DT0H
+fd7 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 02:30:00 EST America/New_York = P1DT1H
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt
new file mode 100644
index 0000000000..72351d37e1
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3-fs.phpt
@@ -0,0 +1,67 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 3, fs)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--XFAIL--
+Still not quite right
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s T e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Forward Transitions, sub().
+ */
+
+$end = new DateTime('2010-03-14 03:00:00');
+$interval_spec = 'PT1S';
+$interval = new DateInterval($interval_spec);
+echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-03-14 04:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-03-14 03:30:00');
+$interval_spec = 'PT22H';
+$interval = new DateInterval($interval_spec);
+echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-03-14 01:30:00');
+$interval_spec = 'PT21H';
+$interval = new DateInterval($interval_spec);
+echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-03-14 01:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-03-15 03:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+
+$end = new DateTime('2010-03-15 02:30:00');
+$interval_spec = 'P1D';
+$interval = new DateInterval($interval_spec);
+echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = "
+ . $end->sub($interval)->format($date_format) . "\n";
+?>
+--EXPECT--
+fs1 2010-03-14 03:00:00 EDT America/New_York - PT1S = 2010-03-14 01:59:59 EST America/New_York
+fs2 2010-03-14 04:30:00 EDT America/New_York - P1D = 2010-03-13 04:30:00 EST America/New_York
+fs3 2010-03-14 03:30:00 EDT America/New_York - PT22H = 2010-03-13 04:30:00 EST America/New_York
+fs4 2010-03-14 01:30:00 EST America/New_York - PT21H = 2010-03-13 04:30:00 EST America/New_York
+fs5 2010-03-14 01:30:00 EST America/New_York - P1D = 2010-03-13 01:30:00 EST America/New_York
+fs6 2010-03-15 03:30:00 EDT America/New_York - P1D = 2010-03-14 03:30:00 EDT America/New_York
+fs7 2010-03-15 02:30:00 EDT America/New_York - P1D = 2010-03-14 03:30:00 EDT America/New_York
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt
deleted file mode 100644
index 855fe4ef65..0000000000
--- a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt
+++ /dev/null
@@ -1,399 +0,0 @@
---TEST--
-RFC: DateTime and Daylight Saving Time Transitions (zone type 3)
---CREDITS--
-Daniel Convissor <danielc@php.net>
---XFAIL--
-RFC not implemented yet
---FILE--
-<?php
-
-date_default_timezone_set('America/New_York');
-$date_format = 'Y-m-d H:i:s T e';
-$interval_format = 'P%dDT%hH';
-
-/*
- * Forward Transitions, diff().
- */
-
-$end = new DateTime('2010-03-14 03:00:00');
-$start = new DateTime('2010-03-14 01:59:59');
-echo 'fd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
-
-$end = new DateTime('2010-03-14 04:30:00');
-$start = new DateTime('2010-03-13 04:30:00');
-echo 'fd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-03-14 03:30:00');
-$start = new DateTime('2010-03-13 04:30:00');
-echo 'fd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-03-14 01:30:00');
-$start = new DateTime('2010-03-13 04:30:00');
-echo 'fd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-03-14 01:30:00');
-$start = new DateTime('2010-03-13 01:30:00');
-echo 'fd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-03-14 03:30:00');
-$start = new DateTime('2010-03-13 03:30:00');
-echo 'fd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-03-14 03:30:00');
-$start = new DateTime('2010-03-13 02:30:00');
-echo 'fd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-echo "\n";
-
-/*
- * Forward Transitions, add().
- */
-
-$start = new DateTime('2010-03-14 01:59:59');
-$interval_spec = 'PT1S';
-$interval = new DateInterval($interval_spec);
-echo 'fa1 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-03-13 04:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fa2 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-03-13 04:30:00');
-$interval_spec = 'PT22H';
-$interval = new DateInterval($interval_spec);
-echo 'fa3 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-03-13 04:30:00');
-$interval_spec = 'PT21H';
-$interval = new DateInterval($interval_spec);
-echo 'fa4 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-03-13 01:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fa5 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-03-13 02:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fa6 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-echo "\n";
-
-/*
- * Forward Transitions, sub().
- */
-
-$end = new DateTime('2010-03-14 03:00:00');
-$interval_spec = 'PT1S';
-$interval = new DateInterval($interval_spec);
-echo 'fs1 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-03-14 04:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fs2 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-03-14 03:30:00');
-$interval_spec = 'PT22H';
-$interval = new DateInterval($interval_spec);
-echo 'fs3 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-03-14 01:30:00');
-$interval_spec = 'PT21H';
-$interval = new DateInterval($interval_spec);
-echo 'fs4 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-03-14 01:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fs5 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-03-15 03:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fs6 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-03-15 02:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'fs7 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-echo "\n";
-
-
-/*
- * For backward transitions, must create objects with zone type 2
- * where specifying Daylight or Standard time is required
- * then converting them to zone type 3.
- */
-
-$tz = new DateTimeZone('America/New_York');
-
-/*
- * Backward Transitions, diff().
- */
-
-$end = new DateTime('2010-11-07 01:00:00 EST');
-$end->setTimeZone($tz);
-$start = new DateTime('2010-11-07 01:59:59');
-echo 'bd1 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format('PT%hH%iM%sS') . "\n";
-
-$end = new DateTime('2010-11-07 04:30:00');
-$start = new DateTime('2010-11-06 04:30:00');
-echo 'bd2 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-11-07 03:30:00');
-$start = new DateTime('2010-11-06 04:30:00');
-echo 'bd3 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-11-07 02:30:00');
-$start = new DateTime('2010-11-06 04:30:00');
-echo 'bd4 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00 EST');
-$end->setTimeZone($tz);
-$start = new DateTime('2010-11-06 04:30:00');
-echo 'bd5 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00 EDT');
-$end->setTimeZone($tz);
-$start = new DateTime('2010-11-06 04:30:00');
-echo 'bd6 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00');
-$start = new DateTime('2010-11-06 01:30:00');
-echo 'bd7 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00 EST');
-$end->setTimeZone($tz);
-$start = new DateTime('2010-11-06 01:30:00');
-echo 'bd8 ' . $end->format($date_format) . ' - ' . $start->format($date_format)
- . ' = ' . $start->diff($end)->format($interval_format) . "\n";
-
-echo "\n";
-
-/*
- * Backward Transitions, add().
- */
-
-$start = new DateTime('2010-11-07 01:59:59');
-$interval_spec = 'PT1S';
-$interval = new DateInterval($interval_spec);
-echo 'ba1 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 04:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'ba2 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 04:30:00');
-$interval_spec = 'PT24H';
-$interval = new DateInterval($interval_spec);
-echo 'ba3 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 04:30:00');
-$interval_spec = 'PT23H';
-$interval = new DateInterval($interval_spec);
-echo 'ba4 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 04:30:00');
-$interval_spec = 'PT22H';
-$interval = new DateInterval($interval_spec);
-echo 'ba5 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 04:30:00');
-$interval_spec = 'PT21H';
-$interval = new DateInterval($interval_spec);
-echo 'ba6 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 01:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'ba7 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 01:30:00');
-$interval_spec = 'P1DT1H';
-$interval = new DateInterval($interval_spec);
-echo 'ba8 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 04:30:00');
-$interval_spec = 'PT25H';
-$interval = new DateInterval($interval_spec);
-echo 'ba9 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 03:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'ba10 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-$start = new DateTime('2010-11-06 02:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'ba11 ' . $start->format($date_format) . " + $interval_spec = "
- . $start->add($interval)->format($date_format) . "\n";
-
-echo "\n";
-
-/*
- * Backward Transitions, sub().
- */
-
-$end = new DateTime('2010-11-07 01:00:00 EST');
-$end->setTimeZone($tz);
-$interval_spec = 'PT1S';
-$interval = new DateInterval($interval_spec);
-echo 'bs1 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 04:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'bs2 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 03:30:00');
-$interval_spec = 'PT24H';
-$interval = new DateInterval($interval_spec);
-echo 'bs3 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 02:30:00');
-$interval_spec = 'PT23H';
-$interval = new DateInterval($interval_spec);
-echo 'bs4 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00 EST');
-$end->setTimeZone($tz);
-$interval_spec = 'PT22H';
-$interval = new DateInterval($interval_spec);
-echo 'bs5 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00 EDT');
-$end->setTimeZone($tz);
-$interval_spec = 'PT21H';
-$interval = new DateInterval($interval_spec);
-echo 'bs6 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'bs7 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 01:30:00 EST');
-$end->setTimeZone($tz);
-$interval_spec = 'P1DT1H';
-$interval = new DateInterval($interval_spec);
-echo 'bs8 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 03:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'bs9 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-$end = new DateTime('2010-11-07 02:30:00');
-$interval_spec = 'P1D';
-$interval = new DateInterval($interval_spec);
-echo 'bs10 ' . $end->format($date_format) . " - $interval_spec = "
- . $end->sub($interval)->format($date_format) . "\n";
-
-?>
---EXPECT--
-fd1 2010-03-14 03:00:00 EDT America/New_York - 2010-03-14 01:59:59 EST America/New_York = PT0H0M1S
-fd2 2010-03-14 04:30:00 EDT America/New_York - 2010-03-13 04:30:00 EST America/New_York = P1DT0H
-fd3 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 04:30:00 EST America/New_York = P0DT22H
-fd4 2010-03-14 01:30:00 EST America/New_York - 2010-03-13 04:30:00 EST America/New_York = P0DT21H
-fd5 2010-03-14 01:30:00 EST America/New_York - 2010-03-13 01:30:00 EST America/New_York = P1DT0H
-fd6 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 03:30:00 EST America/New_York = P1DT0H
-fd7 2010-03-14 03:30:00 EDT America/New_York - 2010-03-13 02:30:00 EST America/New_York = P1DT1H
-
-fa1 2010-03-14 01:59:59 EST America/New_York + PT1S = 2010-03-14 03:00:00 EDT America/New_York
-fa2 2010-03-13 04:30:00 EST America/New_York + P1D = 2010-03-14 04:30:00 EDT America/New_York
-fa3 2010-03-13 04:30:00 EST America/New_York + PT22H = 2010-03-14 03:30:00 EDT America/New_York
-fa4 2010-03-13 04:30:00 EST America/New_York + PT21H = 2010-03-14 01:30:00 EST America/New_York
-fa5 2010-03-13 01:30:00 EST America/New_York + P1D = 2010-03-14 01:30:00 EST America/New_York
-fa6 2010-03-13 02:30:00 EST America/New_York + P1D = 2010-03-14 03:30:00 EDT America/New_York
-
-fs1 2010-03-14 03:00:00 EDT America/New_York - PT1S = 2010-03-14 01:59:59 EST America/New_York
-fs2 2010-03-14 04:30:00 EDT America/New_York - P1D = 2010-03-13 04:30:00 EST America/New_York
-fs3 2010-03-14 03:30:00 EDT America/New_York - PT22H = 2010-03-13 04:30:00 EST America/New_York
-fs4 2010-03-14 01:30:00 EST America/New_York - PT21H = 2010-03-13 04:30:00 EST America/New_York
-fs5 2010-03-14 01:30:00 EST America/New_York - P1D = 2010-03-13 01:30:00 EST America/New_York
-fs6 2010-03-15 03:30:00 EDT America/New_York - P1D = 2010-03-14 03:30:00 EDT America/New_York
-fs7 2010-03-15 03:30:00 EDT America/New_York - P1D = 2010-03-14 03:30:00 EDT America/New_York
-
-bd1 2010-11-07 01:00:00 EST America/New_York - 2010-11-07 01:59:59 EDT America/New_York = PT0H0M1S
-bd2 2010-11-07 04:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P1DT0H
-bd3 2010-11-07 03:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT24H
-bd4 2010-11-07 02:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT23H
-bd5 2010-11-07 01:30:00 EST America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT22H
-bd6 2010-11-07 01:30:00 EDT America/New_York - 2010-11-06 04:30:00 EDT America/New_York = P0DT21H
-bd7 2010-11-07 01:30:00 EDT America/New_York - 2010-11-06 01:30:00 EDT America/New_York = P1DT0H
-bd8 2010-11-07 01:30:00 EST America/New_York - 2010-11-06 01:30:00 EDT America/New_York = P1DT1H
-
-ba1 2010-11-07 01:59:59 EDT America/New_York + PT1S = 2010-11-07 01:00:00 EST America/New_York
-ba2 2010-11-06 04:30:00 EDT America/New_York + P1D = 2010-11-07 04:30:00 EST America/New_York
-ba3 2010-11-06 04:30:00 EDT America/New_York + PT24H = 2010-11-07 03:30:00 EST America/New_York
-ba4 2010-11-06 04:30:00 EDT America/New_York + PT23H = 2010-11-07 02:30:00 EST America/New_York
-ba5 2010-11-06 04:30:00 EDT America/New_York + PT22H = 2010-11-07 01:30:00 EST America/New_York
-ba6 2010-11-06 04:30:00 EDT America/New_York + PT21H = 2010-11-07 01:30:00 EDT America/New_York
-ba7 2010-11-06 01:30:00 EDT America/New_York + P1D = 2010-11-07 01:30:00 EDT America/New_York
-ba8 2010-11-06 01:30:00 EDT America/New_York + P1DT1H = 2010-11-07 01:30:00 EST America/New_York
-ba9 2010-11-06 04:30:00 EDT America/New_York + PT25H = 2010-11-07 04:30:00 EST America/New_York
-ba10 2010-11-06 03:30:00 EDT America/New_York + P1D = 2010-11-07 03:30:00 EST America/New_York
-ba11 2010-11-06 02:30:00 EDT America/New_York + P1D = 2010-11-07 02:30:00 EST America/New_York
-
-bs1 2010-11-07 01:00:00 EST America/New_York - PT1S = 2010-11-07 01:59:59 EDT America/New_York
-bs2 2010-11-07 04:30:00 EST America/New_York - P1D = 2010-11-06 04:30:00 EDT America/New_York
-bs3 2010-11-07 03:30:00 EST America/New_York - PT24H = 2010-11-06 04:30:00 EDT America/New_York
-bs4 2010-11-07 02:30:00 EST America/New_York - PT23H = 2010-11-06 04:30:00 EDT America/New_York
-bs5 2010-11-07 01:30:00 EST America/New_York - PT22H = 2010-11-06 04:30:00 EDT America/New_York
-bs6 2010-11-07 01:30:00 EDT America/New_York - PT21H = 2010-11-06 04:30:00 EDT America/New_York
-bs7 2010-11-07 01:30:00 EDT America/New_York - P1D = 2010-11-06 01:30:00 EDT America/New_York
-bs8 2010-11-07 01:30:00 EST America/New_York - P1DT1H = 2010-11-06 00:30:00 EDT America/New_York
-bs9 2010-11-07 03:30:00 EST America/New_York - P1D = 2010-11-06 03:30:00 EDT America/New_York
-bs10 2010-11-07 02:30:00 EST America/New_York - P1D = 2010-11-06 02:30:00 EDT America/New_York