Annotation of embedaddon/php/ext/date/tests/date_sub_basic.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test date_sub() function : basic functionality 
        !             3: --CREDITS--
        !             4: Felix De Vliegher <felix.devliegher@gmail.com>
        !             5: --SKIPIF--
        !             6: <?php if (!function_exists('date_sub')) echo "skip: date_sub() function not found!"; ?>
        !             7: --FILE--
        !             8: <?php
        !             9: date_default_timezone_set('UTC');
        !            10: /* Prototype  : void date_sub(DateTime object, DateInterval interval)
        !            11:  * Description: Subtracts an interval from the current date in object.
        !            12:  * Source code: ext/date/php_date.c
        !            13:  * Alias to functions: 
        !            14:  */
        !            15: 
        !            16: echo "*** Testing date_sub() : basic functionality ***\n";
        !            17: 
        !            18: // Initialise all required variables
        !            19: $startDate = '2008-01-01 12:25';
        !            20: $format = 'Y-m-d H:i:s';
        !            21: $intervals = array(
        !            22:        'P3Y6M4DT12H30M5S',
        !            23:        'P0D',
        !            24:        'P2DT1M',
        !            25:        'P1Y2MT23H43M150S'
        !            26: );
        !            27: 
        !            28: $d = new DateTime($startDate);
        !            29: var_dump( $d->format($format) );
        !            30: 
        !            31: foreach($intervals as $interval) {
        !            32:        date_sub($d, new DateInterval($interval) );
        !            33:        var_dump( $d->format($format) );
        !            34: }
        !            35: 
        !            36: ?>
        !            37: ===DONE===
        !            38: --EXPECTF--
        !            39: *** Testing date_sub() : basic functionality ***
        !            40: string(19) "2008-01-01 12:25:00"
        !            41: string(19) "2004-06-26 23:54:55"
        !            42: string(19) "2004-06-26 23:54:55"
        !            43: string(19) "2004-06-24 23:53:55"
        !            44: string(19) "2003-04-24 00:08:25"
        !            45: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>