Bug #79182 [NEW]: IntlDateFormatter::formatObject fails with timezone type 2
| From: | _php dot net at jantvrdik dot com | Date: | Tue, 28 Jan 2020 13:00:28 +0000 |
| Subject: | Bug #79182 [NEW]: IntlDateFormatter::formatObject fails with timezone type 2 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-225189@lists.php.net to get a copy of this message | ||
From: _php dot net at jantvrdik dot com
Operating system: Linux
PHP version: 7.4.2
Package: Date/time related
Bug Type: Bug
Bug description:IntlDateFormatter::formatObject fails with timezone type 2
Description:
------------
IntlDateFormatter::formatObject() fails when date has timezone type 2.
Type 1 and 3 work fine. IntlDateFormatter::format() also works fine.
Test script:
---------------
<?php declare(strict_types = 1);
$typeOne = new DateTimeImmutable('today', new DateTimeZone('+0000'));
$typeTwo = new DateTimeImmutable('today', new DateTimeZone('Z'));
$typeThree = new DateTimeImmutable('today', new DateTimeZone('UTC'));
$locale = 'en';
$format = 'd. MMMM';
foreach ([$typeOne, $typeTwo, $typeThree] as $date) {
var_dump($date);
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL,
IntlDateFormatter::FULL, null, null, $format);
var_dump($formatter->format($date));
var_dump(IntlDateFormatter::formatObject($date, $format, $locale));
echo "\n\n\n";
}
Expected result:
----------------
object(DateTimeImmutable)#1 (3) {
["date"]=>
string(26) "2020-01-28 00:00:00.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
string(11) "28. January"
string(11) "28. January"
object(DateTimeImmutable)#2 (3) {
["date"]=>
string(26) "2020-01-28 00:00:00.000000"
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
}
string(11) "28. January"
string(11) "28. January"
object(DateTimeImmutable)#3 (3) {
["date"]=>
string(26) "2020-01-28 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
string(11) "28. January"
string(11) "28. January"
Actual result:
--------------
object(DateTimeImmutable)#1 (3) {
["date"]=>
string(26) "2020-01-28 00:00:00.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
string(11) "28. January"
string(11) "28. January"
object(DateTimeImmutable)#2 (3) {
["date"]=>
string(26) "2020-01-28 00:00:00.000000"
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "Z"
}
string(11) "28. January"
bool(false)
object(DateTimeImmutable)#3 (3) {
["date"]=>
string(26) "2020-01-28 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
string(11) "28. January"
string(11) "28. January"
--
Edit bug report at https://bugs.php.net/bug.php?id=79182&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79182&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79182&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79182&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79182&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79182&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79182&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79182&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79182&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79182&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79182&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79182&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79182&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79182&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79182&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79182&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79182&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79182&r=mysqlcfg