Annotation of embedaddon/php/ext/date/tests/bug49059.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #49059 (DateTime::diff() repeats previous sub() operation)
! 3: --FILE--
! 4: <?php
! 5: date_default_timezone_set('Asia/Calcutta');
! 6:
! 7: $date1 = date_create("2009-03-27");
! 8: $date2 = date_create("2009-03-01");
! 9: print "\$date1 at init: " . $date1->format("Y-m-d") . "\n";
! 10: print "\$date2 at init: " . $date2->format("Y-m-d") . "\n";
! 11: $diff = $date1->diff($date2);
! 12: print "\$date1 after first diff: " . $date1->format("Y-m-d") . "\n";
! 13: print "\$diff->days after first diff: " . $diff->days . "\n";
! 14: $date1 = $date1->sub(new DateInterval("P2D"));
! 15: print "\$date1 after sub: " . $date1->format("Y-m-d") . "\n";
! 16: $diff = $date1->diff($date2);
! 17: print "\$date1 after second diff (called at \$date1): " .
! 18: $date1->format("Y-m-d") . "\n";
! 19: print "\$diff->days after second diff: " . $diff->days . "\n";
! 20: $diff = $date2->diff($date1);
! 21: print "\$date1 after third diff (called at \$date2): " .
! 22: $date1->format("Y-m-d") . "\n";
! 23: print "\$diff->days after third diff: " . $diff->days . "\n";
! 24: ?>
! 25: --EXPECT--
! 26: $date1 at init: 2009-03-27
! 27: $date2 at init: 2009-03-01
! 28: $date1 after first diff: 2009-03-27
! 29: $diff->days after first diff: 26
! 30: $date1 after sub: 2009-03-25
! 31: $date1 after second diff (called at $date1): 2009-03-25
! 32: $diff->days after second diff: 24
! 33: $date1 after third diff (called at $date2): 2009-03-25
! 34: $diff->days after third diff: 24
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>