summaryrefslogtreecommitdiff
path: root/ext/date/tests/date_sub_basic.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/date/tests/date_sub_basic.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/date/tests/date_sub_basic.phpt')
-rw-r--r--ext/date/tests/date_sub_basic.phpt45
1 files changed, 45 insertions, 0 deletions
diff --git a/ext/date/tests/date_sub_basic.phpt b/ext/date/tests/date_sub_basic.phpt
new file mode 100644
index 0000000..0e12704
--- /dev/null
+++ b/ext/date/tests/date_sub_basic.phpt
@@ -0,0 +1,45 @@
+--TEST--
+Test date_sub() function : basic functionality
+--CREDITS--
+Felix De Vliegher <felix.devliegher@gmail.com>
+--SKIPIF--
+<?php if (!function_exists('date_sub')) echo "skip: date_sub() function not found!"; ?>
+--FILE--
+<?php
+date_default_timezone_set('UTC');
+/* Prototype : void date_sub(DateTime object, DateInterval interval)
+ * Description: Subtracts an interval from the current date in object.
+ * Source code: ext/date/php_date.c
+ * Alias to functions:
+ */
+
+echo "*** Testing date_sub() : basic functionality ***\n";
+
+// Initialise all required variables
+$startDate = '2008-01-01 12:25';
+$format = 'Y-m-d H:i:s';
+$intervals = array(
+ 'P3Y6M4DT12H30M5S',
+ 'P0D',
+ 'P2DT1M',
+ 'P1Y2MT23H43M150S'
+);
+
+$d = new DateTime($startDate);
+var_dump( $d->format($format) );
+
+foreach($intervals as $interval) {
+ date_sub($d, new DateInterval($interval) );
+ var_dump( $d->format($format) );
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing date_sub() : basic functionality ***
+string(19) "2008-01-01 12:25:00"
+string(19) "2004-06-26 23:54:55"
+string(19) "2004-06-26 23:54:55"
+string(19) "2004-06-24 23:53:55"
+string(19) "2003-04-24 00:08:25"
+===DONE===