Annotation of embedaddon/php/ext/date/tests/bug50055.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #50555 (DateTime::sub() allows 'relative' time modifications).
! 3: --FILE--
! 4: <?php
! 5: $now = '2010-03-07 13:21:38 UTC';
! 6: //positive DateInterval
! 7: $da1 = date_create( $now );
! 8: $ds1 = date_create( $now );
! 9: $i = DateInterval::createFromDateString('third Tuesday of next month');
! 10: echo $da1->format( DateTime::ISO8601 ), "\n";
! 11: echo date_add($da1, $i)->format( DateTime::ISO8601 ), "\n";
! 12: date_sub($ds1, $i);
! 13:
! 14: //negative DateInterval
! 15: $da2 = date_create( $now );
! 16: $ds2 = date_create( $now );
! 17: $i2 = DateInterval::createFromDateString('third Tuesday of last month');
! 18: echo $da2->format( DateTime::ISO8601 ), "\n";
! 19: echo date_add($da2, $i2)->format( DateTime::ISO8601 ), "\n";//works
! 20: date_sub($ds2, $i);
! 21: ?>
! 22: --EXPECTF--
! 23: 2010-03-07T13:21:38+0000
! 24: 2010-04-20T13:21:38+0000
! 25:
! 26: Warning: date_sub(): Only non-special relative time specifications are supported for subtraction in %sbug50055.php on line 9
! 27: 2010-03-07T13:21:38+0000
! 28: 2010-02-16T13:21:38+0000
! 29:
! 30: Warning: date_sub(): Only non-special relative time specifications are supported for subtraction in %sbug50055.php on line 17
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>