phpt test for dateinterval

From: Date: Sun, 10 May 2009 19:30:02 +0000
Subject: phpt test for dateinterval
Groups: php.qa 
Request: Send a blank email to php-qa+get-64944@lists.php.net to get a copy of this message
Hello all: Not sure where to put this or what to do with it, but the DateInterval constructor time parsing *seems* to be broken. From what I can tell, it'd probably affect other things as well, but I'm not sure. Here's my test: --TEST-- Test dateinterval constructor with only time --CREDITS-- Michael Kimsal <michael@kimsal.com> --FILE-- <?php date_default_timezone_set('UTC'); echo "*** Testing date interval constructor with only time ***\n"; $di = new DateInterval("T1H"); print_r($di); ?> ===DONE=== --EXPECTF-- *** Testing date interval constructor with only time *** DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 1 [i] => 0 [s] => 0 [invert] => 0 [days] => 0 ) ===DONE=== and the results ---- EXPECTED OUTPUT *** Testing date interval constructor with only time *** DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 1 [i] => 0 [s] => 0 [invert] => 0 [days] => 0 ) ===DONE=== ---- ACTUAL OUTPUT *** Testing date interval constructor with only time *** Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct(): Unknown or bad format (T1H)' in /home/michael/apps/php-5.3.0RC2/ext/date/tests/date_interval_only_time.php:6 Stack trace: #0 /home/michael/apps/php-5.3.0RC2/ext/date/tests/date_interval_only_time.php(6): DateInterval->__construct('T1H') #1 {main} thrown in /home/michael/apps/php-5.3.0RC2/ext/date/tests/date_interval_only_time.php on line 6 ---- FAILED Given that there's no docs on dateinterval (yet?) http://www.php.net/manual/en/class.dateinterval.php I can't really say it's not working according to the manual, but it doesn't seem right. I should be able to add 1 hour to a time with this new approach, right? -- Michael Kimsal http://jsmag.com - for javascript developers http://groovymag.com - for groovy developers 919.827.4724

« previous php.qa (#64944) next »