php-src/ext/date/tests/bug51393.phpt
2010-07-06 00:25:52 +00:00

76 lines
1.7 KiB
PHP

--TEST--
Bug #51393 (DateTime::createFromFormat() fails if format string contains timezone)
--INI--
date.timezone=UTC
--FILE--
<?php
$dt = DateTime::createFromFormat('O', '+0800');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('P', '+08:00');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('O', '-0800');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('P', '-08:00');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[O]', '[+0800]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[P]', '[+08:00]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[O]', '[-0800]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[P]', '[-08:00]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('O', 'GMT+0800');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('P', 'GMT+08:00');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('O', 'GMT-0800');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('P', 'GMT-08:00');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[O]', '[GMT+0800]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[P]', '[GMT+08:00]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[O]', '[GMT-0800]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('[P]', '[GMT-08:00]');
var_dump($dt->getOffset());
$dt = DateTime::createFromFormat('O', 'invalid');
var_dump($dt);
?>
--EXPECT--
int(28800)
int(28800)
int(-28800)
int(-28800)
int(28800)
int(28800)
int(-28800)
int(-28800)
int(28800)
int(28800)
int(-28800)
int(-28800)
int(28800)
int(28800)
int(-28800)
int(-28800)
bool(false)