Edit report at http://bugs.php.net/bug.php?id=52283&edit=1

 ID:                 52283
 Updated by:         s...@php.net
 Reported by:        danikas2k2 at gmail dot com
 Summary:            IntlDateFormatter invalid parsing with YYYY
-Status:             Assigned
+Status:             Bogus
 Type:               Bug
 Package:            I18N and L10N related
 Operating System:   WinXP
 PHP Version:        5.3.2
 Assigned To:        stas
 Block user comment: N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

YYYY is not a regular year (that's yyyy). It's a year from "week date"
format, see here: http://en.wikipedia.org/wiki/ISO_8601#Week_dates

it's kind of funny format, since it speaks in whole weeks, so if part of
week was in 2006 and part of 2007, giving just year number actually can
send you to a last week of previous year. As an example goes in wiki,
2008-12-29 is written "2009-W01-1". YYYY and MM thus won't mix that
well. Use yyyy.


Previous Comments:
------------------------------------------------------------------------
[2010-07-08 13:05:43] johan...@php.net

Stas, please look into this. Thanks. I don't know whether that might be
expected or is an icu issue or ...

------------------------------------------------------------------------
[2010-07-08 09:29:39] danikas2k2 at gmail dot com

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 this bug report at http://bugs.php.net/bug.php?id=52283&edit=1

Reply via email to