diff options
author | Raghubansh Kumar <kraghuba@php.net> | 2008-06-17 13:14:45 +0000 |
---|---|---|
committer | Raghubansh Kumar <kraghuba@php.net> | 2008-06-17 13:14:45 +0000 |
commit | e70880d3b1615c733dfe1a00924f460ef82e5998 (patch) | |
tree | 929f81dc363f1e76828abb05cb1d2ad009ee702e /ext | |
parent | 0b5f3a189513b6bbb57b940ece4381b6d291d8e5 (diff) | |
download | php-git-e70880d3b1615c733dfe1a00924f460ef82e5998.tar.gz |
Committed for Felix De Vliegher, TestFest Task No: 123, Tested on RHEL5, WinXP
Diffstat (limited to 'ext')
-rw-r--r-- | ext/date/tests/date_sub_basic.phpt | 46 |
1 files changed, 46 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 0000000000..8ebf02a712 --- /dev/null +++ b/ext/date/tests/date_sub_basic.phpt @@ -0,0 +1,46 @@ +--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!"; ?> +--INI-- +date.timezone=UTC +--FILE-- +<?php +/* 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=== |