From:
Operating system: WinXP
PHP version: 5.3.2
Package: I18N and L10N related
Bug Type: Bug
Bug description:IntlDateFormatter invalid parsing with YYYY
Description:
------------
Parsing a value with YYYY in the pattern returns unexpected results.
Formatting
the value using the YYYY in the pattern works perfect.
Test script:
---------------
$fmt = new IntlDateFormatter('lt_LT', IntlDateFormatter::FULL,
IntlDateFormatter::FULL, 'Europe/Vilnius', IntlDateFormatter::GREGORIAN);
$value = '2007-10-01'; // notice, that 2007-01-01 equals to 2007-W01-1
$variants = array();
$fmt->setPattern('yyyy');
$pts = $fmt->parse($value);
$variants[] = array($pts, $fmt->format($pts));
$fmt->setPattern('yyyy-MM');
$pts = $fmt->parse($value);
$variants[] = array($pts, $fmt->format($pts));
$fmt->setPattern('yyyy-MM-dd');
$pts = $fmt->parse($value);
$variants[] = array($pts, $fmt->format($pts));
$fmt->setPattern('YYYY');
$pts = $fmt->parse($value);
$variants[] = array($pts, $fmt->format($pts));
$fmt->setPattern('YYYY-MM');
$pts = $fmt->parse($value);
$variants[] = array($pts, $fmt->format($pts));
$fmt->setPattern('YYYY-MM-dd');
$pts = $fmt->parse($value);
$variants[] = array($pts, $fmt->format($pts));
print_r($variants);
Expected result:
----------------
array (
0 =>
array (
0 => 1167602400,
1 => '2007',
),
1 =>
array (
0 => 1191186000,
1 => '2007-10',
),
2 =>
array (
0 => 1191186000,
1 => '2007-10-01',
),
3 =>
array (
0 => 1167602400,
1 => '2007',
),
4 =>
array (
0 => 1191186000,
1 => '2007-10',
),
5 =>
array (
0 => 1191186000,
1 => '2007-10-01',
),
)
Actual result:
--------------
array (
0 =>
array (
0 => 1167602400,
1 => '2007',
),
1 =>
array (
0 => 1191186000,
1 => '2007-10',
),
2 =>
array (
0 => 1191186000,
1 => '2007-10-01',
),
3 =>
array (
0 => 1166997600,
1 => '2006',
),
4 =>
array (
0 => 1166997600,
1 => '2006-12',
),
5 =>
array (
0 => 23576400,
1 => '1970-10-01',
),
)
--
Edit bug report at http://bugs.php.net/bug.php?id=52283&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52283&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52283&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52283&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52283&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52283&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52283&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52283&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52283&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52283&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52283&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52283&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52283&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52283&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52283&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52283&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52283&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52283&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52283&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52283&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52283&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52283&r=mysqlcfg