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

From: Date: Fri, 11 Mar 2016 11:10:44 +0000
Subject: Bug #71790 [Opn->Csd]: Wrong Year formatting for 3rd Jan 2016 (returned 2015) on some locales.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199755@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71790&edit=1 ID: 71790 User updated by: ignasi35 at gmail dot com Reported by: ignasi35 at gmail dot com Summary: Wrong Year formatting for 3rd Jan 2016 (returned 2015) on some locales. -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: Debian/CentOS/Mac PHP Version: 5.6.19 Block user comment: N Private report: N New Comment: closing Previous Comments: ------------------------------------------------------------------------ [2016-03-11 11:10:18] ignasi35 at gmail dot com This is not a bug. The week in year ('YYYY') depends no the locale, I should have used 'yyyy' ------------------------------------------------------------------------ [2016-03-11 09:27:28] ignasi35 at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=71790&edit=1

« previous php.bugs (#199755) next »