php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71516 IntlDateFormatter losts locale if pattern is set via constructor
Submitted: 2016-02-03 16:41 UTC Modified: -
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: maxxarts at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 7.0.3RC1 OS: CentOS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maxxarts at gmail dot com
New email:
PHP Version: OS:

 

 [2016-02-03 16:41 UTC] maxxarts at gmail dot com
Description:
------------
When IntlDateFormatter is created with pattern, getLocale always return empty string. If pattern is not set or set via setPattern - all is OK.

Test script:
---------------
<?php

$goodFormatter = new IntlDateFormatter("ru_RU", IntlDateFormatter::FULL, IntlDateFormatter::FULL, new DateTimeZone("UTC"));
$badFormatter = new IntlDateFormatter("ru_RU", IntlDateFormatter::FULL, IntlDateFormatter::FULL, new DateTimeZone("UTC"), null, "d MMM");
$badFormatter2 = new IntlDateFormatter("ru_RU", IntlDateFormatter::FULL, IntlDateFormatter::FULL, new DateTimeZone("UTC"));
$badFormatter2->setPattern("d MMM");

echo "Formatter without pattern: " . $goodFormatter->getLocale() . PHP_EOL;
echo "Formatter with pattern: " . $badFormatter->getLocale() . PHP_EOL;
echo "Formatter with pattern set later: " . $badFormatter2->getLocale() . PHP_EOL;

Expected result:
----------------
getLocale() always must return original locale.

Actual result:
--------------
Proof - https://3v4l.org/S1CsZ

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-08 07:01 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=49d31fa01d1cfe4515bd6f1cdb256374701a4489
Log: Fixed bug #71516 IntlDateFormatter losts locale if pattern is set via constructor
 [2016-04-08 07:01 UTC] ab@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=49d31fa01d1cfe4515bd6f1cdb256374701a4489
Log: Fixed bug #71516 IntlDateFormatter losts locale if pattern is set via constructor
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC