Bug #71790 [NEW]: Wrong Year formatting for 3rd Jan 2016 (returned 2015) on some locales.

From: Date: Fri, 11 Mar 2016 09:27:33 +0000
Subject: Bug #71790 [NEW]: Wrong Year formatting for 3rd Jan 2016 (returned 2015) on some locales.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199751@lists.php.net to get a copy of this message
From:             ignasi35 at gmail dot com
Operating system: Debian/CentOS/Mac
PHP version:      5.6.19
Package:          Date/time related
Bug Type:         Bug
Bug description:Wrong Year formatting for 3rd Jan 2016 (returned 2015) on some locales.

Description:
------------
---
From manual page: http://www.php.net/book.intl
---

When requesting IntlDateFormatter to format '2016-01-03' using a
specific set of locales with pattern 'YYYY' it returns 2015.

Steps to reproduce:
 - See attached code.

Details:
 - only some locales fail
 - we reproduce the error for dates 2016-01-01, 2016-01-02 and
2016-01-03. It looks like 2016-01-04 triggers the correct output
 - So far, for '2016-01-03' these values fail/pass:
$locale = 'en_UK' ; // UK -> passes
$locale = 'en_US' ; // US -> passes
$locale = 'ru_RU'; // Russian -> passes
$locale = 'es_ES'; // Spanish -> fails
$locale = 'de_DE'; // German -> fails
$locale = 'el_GR'; // Greek -> fails
 - we use the date '2016-01-03' to rule out a TZ-offset issue
 - we tested successfully Russia (ahead of UTC), UK (in UTC) and US
(behind UTC)
 - we found Germany and Spain to fail (both in CET), But also Greece
(not in CET)

This could be a side effect of https://bugs.php.net/bug.php?id=65694. 

Test script:
---------------
<?php
$locale = 'en_US' ; // US -> passes
$locale = 'ru_RU'; // Russian -> passes
$locale = 'es_ES'; // Spanish -> fails
$locale = 'de_DE'; // German -> fails
$locale = 'el_GR'; // Greek -> fails
setlocale(LC_ALL,  $locale  );
echo "$locale \n" ;

$DEFAULT_ZONE = 'Europe/Madrid';
$humantime = "2016-01-03" ;
$time = strtotime($humantime) ;
echo "humantime: $humantime \n" ;
echo "time: $time \n" ;

$pattern = ' YYYY';
$fmt = new IntlDateFormatter( $locale, IntlDateFormatter::NONE,
IntlDateFormatter::NONE, $DEFAULT_ZONE, IntlDateFormatter::GREGORIAN,
$pattern);
echo $fmt->format($time);

Expected result:
----------------
We expected the result to be '2016'

Actual result:
--------------
The output is 2015



-- 
Edit bug report at https://bugs.php.net/bug.php?id=71790&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71790&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71790&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71790&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71790&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71790&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71790&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71790&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71790&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71790&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71790&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71790&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71790&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71790&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71790&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71790&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71790&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71790&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71790&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71790&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71790&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#199751) next »