summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Convissor <danielc@php.net>2011-10-18 21:45:07 +0000
committerDaniel Convissor <danielc@php.net>2011-10-18 21:45:07 +0000
commitf2ce9b406bfd81708c77e51a8f63a7b4a1a9ac25 (patch)
tree0857d585d3685a75ce3a910f0fb5fbfd0a2dff1a
parent07b7ba8b4004596086c0506e2f5a9058aa43ed55 (diff)
downloadphp-git-f2ce9b406bfd81708c77e51a8f63a7b4a1a9ac25.tar.gz
Tests for the DST RFC.
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt380
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt382
-rw-r--r--ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt399
3 files changed, 1161 insertions, 0 deletions
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt
new file mode 100644
index 0000000000..c297608913
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type1.phpt
@@ -0,0 +1,380 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 1)
+--CREDITS--
+Daniel Convissor <danielc@php.net>
+--FILE--
+<?php
+
+date_default_timezone_set('America/New_York');
+$date_format = 'Y-m-d H:i:s e';
+$interval_format = 'P%dDT%hH';
+
+/*
+ * Forward Transitions, diff().
+ */
+
+$end = new DateTime('2010-03-14 03:00:00 -0400');
+$start = new DateTime('2010-03-14 01:59:59 -0500');
+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 -0400');
+$start = new DateTime('2010-03-13 04:30:00 -0500');
+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 -0400');
+$start = new DateTime('2010-03-13 04:30:00 -0500');
+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 -0500');
+$start = new DateTime('2010-03-13 04:30:00 -0500');
+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 -0500');
+$start = new DateTime('2010-03-13 01:30:00 -0500');
+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 -0400');
+$start = new DateTime('2010-03-13 03:30:00 -0500');
+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 -0400');
+$start = new DateTime('2010-03-13 02:30:00 -0500');
+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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0500');
+$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 -0500');
+$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 -0400');
+$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 -0400');
+$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";
+
+/*
+ * Backward Transitions, diff().
+ */
+
+$end = new DateTime('2010-11-07 01:00:00 -0500');
+$start = new DateTime('2010-11-07 01:59:59 -0400');
+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 -0500');
+$start = new DateTime('2010-11-06 04:30:00 -0400');
+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 -0500');
+$start = new DateTime('2010-11-06 04:30:00 -0400');
+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 -0500');
+$start = new DateTime('2010-11-06 04:30:00 -0400');
+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 -0500');
+$start = new DateTime('2010-11-06 04:30:00 -0400');
+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 -0400');
+$start = new DateTime('2010-11-06 04:30:00 -0400');
+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 -0400');
+$start = new DateTime('2010-11-06 01:30:00 -0400');
+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 -0500');
+$start = new DateTime('2010-11-06 01:30:00 -0400');
+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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0400');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -0400');
+$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 -0400');
+$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 -0500');
+$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 -0500');
+$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 -0500');
+$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 -04:00 - 2010-03-14 01:59:59 -05:00 = PT0H0M1S
+fd2 2010-03-14 04:30:00 -04:00 - 2010-03-13 04:30:00 -05:00 = P0DT23H
+fd3 2010-03-14 03:30:00 -04:00 - 2010-03-13 04:30:00 -05:00 = P0DT22H
+fd4 2010-03-14 01:30:00 -05:00 - 2010-03-13 04:30:00 -05:00 = P0DT21H
+fd5 2010-03-14 01:30:00 -05:00 - 2010-03-13 01:30:00 -05:00 = P1DT0H
+fd6 2010-03-14 03:30:00 -04:00 - 2010-03-13 03:30:00 -05:00 = P0DT23H
+fd7 2010-03-14 03:30:00 -04:00 - 2010-03-13 02:30:00 -05:00 = P1DT0H
+
+fa1 2010-03-14 01:59:59 -05:00 + PT1S = 2010-03-14 02:00:00 -05:00
+fa2 2010-03-13 04:30:00 -05:00 + P1D = 2010-03-14 04:30:00 -05:00
+fa3 2010-03-13 04:30:00 -05:00 + PT22H = 2010-03-14 02:30:00 -05:00
+fa4 2010-03-13 04:30:00 -05:00 + PT21H = 2010-03-14 01:30:00 -05:00
+fa5 2010-03-13 01:30:00 -05:00 + P1D = 2010-03-14 01:30:00 -05:00
+fa6 2010-03-13 02:30:00 -05:00 + P1D = 2010-03-14 02:30:00 -05:00
+
+fs1 2010-03-14 03:00:00 -04:00 - PT1S = 2010-03-14 02:59:59 -04:00
+fs2 2010-03-14 04:30:00 -04:00 - P1D = 2010-03-13 04:30:00 -04:00
+fs3 2010-03-14 03:30:00 -04:00 - PT22H = 2010-03-13 05:30:00 -04:00
+fs4 2010-03-14 01:30:00 -05:00 - PT21H = 2010-03-13 04:30:00 -05:00
+fs5 2010-03-14 01:30:00 -05:00 - P1D = 2010-03-13 01:30:00 -05:00
+fs6 2010-03-15 03:30:00 -04:00 - P1D = 2010-03-14 03:30:00 -04:00
+fs7 2010-03-15 02:30:00 -04:00 - P1D = 2010-03-14 02:30:00 -04:00
+
+bd1 2010-11-07 01:00:00 -05:00 - 2010-11-07 01:59:59 -04:00 = PT0H0M1S
+bd2 2010-11-07 04:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P1DT1H
+bd3 2010-11-07 03:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P1DT0H
+bd4 2010-11-07 02:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P0DT23H
+bd5 2010-11-07 01:30:00 -05:00 - 2010-11-06 04:30:00 -04:00 = P0DT22H
+bd6 2010-11-07 01:30:00 -04:00 - 2010-11-06 04:30:00 -04:00 = P0DT21H
+bd7 2010-11-07 01:30:00 -04:00 - 2010-11-06 01:30:00 -04:00 = P1DT0H
+bd8 2010-11-07 01:30:00 -05:00 - 2010-11-06 01:30:00 -04:00 = P1DT1H
+
+ba1 2010-11-07 01:59:59 -04:00 + PT1S = 2010-11-07 02:00:00 -04:00
+ba2 2010-11-06 04:30:00 -04:00 + P1D = 2010-11-07 04:30:00 -04:00
+ba3 2010-11-06 04:30:00 -04:00 + PT24H = 2010-11-07 04:30:00 -04:00
+ba4 2010-11-06 04:30:00 -04:00 + PT23H = 2010-11-07 03:30:00 -04:00
+ba5 2010-11-06 04:30:00 -04:00 + PT22H = 2010-11-07 02:30:00 -04:00
+ba6 2010-11-06 04:30:00 -04:00 + PT21H = 2010-11-07 01:30:00 -04:00
+ba7 2010-11-06 01:30:00 -04:00 + P1D = 2010-11-07 01:30:00 -04:00
+ba8 2010-11-06 01:30:00 -04:00 + P1DT1H = 2010-11-07 02:30:00 -04:00
+ba9 2010-11-06 04:30:00 -04:00 + PT25H = 2010-11-07 05:30:00 -04:00
+ba10 2010-11-06 03:30:00 -04:00 + P1D = 2010-11-07 03:30:00 -04:00
+ba11 2010-11-06 02:30:00 -04:00 + P1D = 2010-11-07 02:30:00 -04:00
+
+bs1 2010-11-07 01:00:00 -05:00 - PT1S = 2010-11-07 00:59:59 -05:00
+bs2 2010-11-07 04:30:00 -05:00 - P1D = 2010-11-06 04:30:00 -05:00
+bs3 2010-11-07 03:30:00 -05:00 - PT24H = 2010-11-06 03:30:00 -05:00
+bs4 2010-11-07 02:30:00 -05:00 - PT23H = 2010-11-06 03:30:00 -05:00
+bs5 2010-11-07 01:30:00 -05:00 - PT22H = 2010-11-06 03:30:00 -05:00
+bs6 2010-11-07 01:30:00 -04:00 - PT21H = 2010-11-06 04:30:00 -04:00
+bs7 2010-11-07 01:30:00 -04:00 - P1D = 2010-11-06 01:30:00 -04:00
+bs8 2010-11-07 01:30:00 -05:00 - P1DT1H = 2010-11-06 00:30:00 -05:00
+bs9 2010-11-07 03:30:00 -05:00 - P1D = 2010-11-06 03:30:00 -05:00
+bs10 2010-11-07 02:30:00 -05:00 - P1D = 2010-11-06 02:30:00 -05:00
diff --git a/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt
new file mode 100644
index 0000000000..5813602513
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type2.phpt
@@ -0,0 +1,382 @@
+--TEST--
+RFC: DateTime and Daylight Saving Time Transitions (zone type 2)
+--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 EDT');
+$start = new DateTime('2010-03-14 01:59:59 EST');
+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 EDT');
+$start = new DateTime('2010-03-13 04:30:00 EST');
+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 EDT');
+$start = new DateTime('2010-03-13 04:30:00 EST');
+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 EST');
+$start = new DateTime('2010-03-13 04:30:00 EST');
+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 EST');
+$start = new DateTime('2010-03-13 01:30:00 EST');
+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 EDT');
+$start = new DateTime('2010-03-13 03:30:00 EST');
+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 EDT');
+$start = new DateTime('2010-03-13 02:30:00 EST');
+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 EST');
+$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 EST');
+$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 EST');
+$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 EST');
+$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 EST');
+$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 EST');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EST');
+$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 EST');
+$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 EDT');
+$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 EDT');
+$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";
+
+/*
+ * Backward Transitions, diff().
+ */
+
+$end = new DateTime('2010-11-07 01:00:00 EST');
+$start = new DateTime('2010-11-07 01:59:59 EDT');
+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 EST');
+$start = new DateTime('2010-11-06 04:30:00 EDT');
+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 EST');
+$start = new DateTime('2010-11-06 04:30:00 EDT');
+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 EST');
+$start = new DateTime('2010-11-06 04:30:00 EDT');
+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');
+$start = new DateTime('2010-11-06 04:30:00 EDT');
+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');
+$start = new DateTime('2010-11-06 04:30:00 EDT');
+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 EDT');
+$start = new DateTime('2010-11-06 01:30:00 EDT');
+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');
+$start = new DateTime('2010-11-06 01:30:00 EDT');
+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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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 EDT');
+$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');
+$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 EST');
+$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 EST');
+$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 EST');
+$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');
+$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');
+$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 EDT');
+$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');
+$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 EST');
+$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 EST');
+$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 EDT - 2010-03-14 01:59:59 EST EST = PT0H0M1S
+fd2 2010-03-14 04:30:00 EDT EDT - 2010-03-13 04:30:00 EST EST = P0DT23H
+fd3 2010-03-14 03:30:00 EDT EDT - 2010-03-13 04:30:00 EST EST = P0DT22H
+fd4 2010-03-14 01:30:00 EST EST - 2010-03-13 04:30:00 EST EST = P0DT21H
+fd5 2010-03-14 01:30:00 EST EST - 2010-03-13 01:30:00 EST EST = P1DT0H
+fd6 2010-03-14 03:30:00 EDT EDT - 2010-03-13 03:30:00 EST EST = P0DT23H
+fd7 2010-03-14 03:30:00 EDT EDT - 2010-03-13 02:30:00 EST EST = P1DT0H
+
+fa1 2010-03-14 01:59:59 EST EST + PT1S = 2010-03-14 02:00:00 EST EST
+fa2 2010-03-13 04:30:00 EST EST + P1D = 2010-03-14 04:30:00 EST EST
+fa3 2010-03-13 04:30:00 EST EST + PT22H = 2010-03-14 02:30:00 EST EST
+fa4 2010-03-13 04:30:00 EST EST + PT21H = 2010-03-14 01:30:00 EST EST
+fa5 2010-03-13 01:30:00 EST EST + P1D = 2010-03-14 01:30:00 EST EST
+fa6 2010-03-13 02:30:00 EST EST + P1D = 2010-03-14 02:30:00 EST EST
+
+fs1 2010-03-14 03:00:00 EDT EDT - PT1S = 2010-03-14 02:59:59 EDT EDT
+fs2 2010-03-14 04:30:00 EDT EDT - P1D = 2010-03-13 04:30:00 EDT EDT
+fs3 2010-03-14 03:30:00 EDT EDT - PT22H = 2010-03-13 05:30:00 EDT EDT
+fs4 2010-03-14 01:30:00 EST EST - PT21H = 2010-03-13 04:30:00 EST EST
+fs5 2010-03-14 01:30:00 EST EST - P1D = 2010-03-13 01:30:00 EST EST
+fs6 2010-03-15 03:30:00 EDT EDT - P1D = 2010-03-14 03:30:00 EDT EDT
+fs7 2010-03-15 02:30:00 EDT EDT - P1D = 2010-03-14 02:30:00 EDT EDT
+
+bd1 2010-11-07 01:00:00 EST EST - 2010-11-07 01:59:59 EDT EDT = PT0H0M1S
+bd2 2010-11-07 04:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P1DT1H
+bd3 2010-11-07 03:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P1DT0H
+bd4 2010-11-07 02:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P0DT23H
+bd5 2010-11-07 01:30:00 EST EST - 2010-11-06 04:30:00 EDT EDT = P0DT22H
+bd6 2010-11-07 01:30:00 EDT EDT - 2010-11-06 04:30:00 EDT EDT = P0DT21H
+bd7 2010-11-07 01:30:00 EDT EDT - 2010-11-06 01:30:00 EDT EDT = P1DT0H
+bd8 2010-11-07 01:30:00 EST EST - 2010-11-06 01:30:00 EDT EDT = P1DT1H
+
+ba1 2010-11-07 01:59:59 EDT EDT + PT1S = 2010-11-07 02:00:00 EDT EDT
+ba2 2010-11-06 04:30:00 EDT EDT + P1D = 2010-11-07 04:30:00 EDT EDT
+ba3 2010-11-06 04:30:00 EDT EDT + PT24H = 2010-11-07 04:30:00 EDT EDT
+ba4 2010-11-06 04:30:00 EDT EDT + PT23H = 2010-11-07 03:30:00 EDT EDT
+ba5 2010-11-06 04:30:00 EDT EDT + PT22H = 2010-11-07 02:30:00 EDT EDT
+ba6 2010-11-06 04:30:00 EDT EDT + PT21H = 2010-11-07 01:30:00 EDT EDT
+ba7 2010-11-06 01:30:00 EDT EDT + P1D = 2010-11-07 01:30:00 EDT EDT
+ba8 2010-11-06 01:30:00 EDT EDT + P1DT1H = 2010-11-07 02:30:00 EDT EDT
+ba9 2010-11-06 04:30:00 EDT EDT + PT25H = 2010-11-07 05:30:00 EDT EDT
+ba10 2010-11-06 03:30:00 EDT EDT + P1D = 2010-11-07 03:30:00 EDT EDT
+ba11 2010-11-06 02:30:00 EDT EDT + P1D = 2010-11-07 02:30:00 EDT EDT
+
+bs1 2010-11-07 01:00:00 EST EST - PT1S = 2010-11-07 00:59:59 EST EST
+bs2 2010-11-07 04:30:00 EST EST - P1D = 2010-11-06 04:30:00 EST EST
+bs3 2010-11-07 03:30:00 EST EST - PT24H = 2010-11-06 03:30:00 EST EST
+bs4 2010-11-07 02:30:00 EST EST - PT23H = 2010-11-06 03:30:00 EST EST
+bs5 2010-11-07 01:30:00 EST EST - PT22H = 2010-11-06 03:30:00 EST EST
+bs6 2010-11-07 01:30:00 EDT EDT - PT21H = 2010-11-06 04:30:00 EDT EDT
+bs7 2010-11-07 01:30:00 EDT EDT - P1D = 2010-11-06 01:30:00 EDT EDT
+bs8 2010-11-07 01:30:00 EST EST - P1DT1H = 2010-11-06 00:30:00 EST EST
+bs9 2010-11-07 03:30:00 EST EST - P1D = 2010-11-06 03:30:00 EST EST
+bs10 2010-11-07 02:30:00 EST EST - P1D = 2010-11-06 02:30:00 EST EST
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
new file mode 100644
index 0000000000..855fe4ef65
--- /dev/null
+++ b/ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt
@@ -0,0 +1,399 @@
+--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