Doc #74562 [Opn->Nab]: DateTimeZone->getLocation() returns false
| From: | heiglandreas@php.net | Date: | Sun, 14 May 2017 18:21:13 +0000 |
| Subject: | Doc #74562 [Opn->Nab]: DateTimeZone->getLocation() returns false | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14689@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74562&edit=1
ID: 74562
Updated by: heiglandreas@php.net
Reported by: schmidt@php.net
Summary: DateTimeZone->getLocation() returns false
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Date/time related
Operating System: Linux
PHP Version: 7.1.4
Block user comment: N
Private report: N
New Comment:
The docs clearly states that the method will return 'false' in an error case. Not
providing a valid timezone IS an error-case.
If you need an array with dummy-values you can always check for a "false" and then create
an array with dummy-values.
Previous Comments:
------------------------------------------------------------------------
[2017-05-10 09:26:11] bugs dot php dot net at chsc dot dk
Related To: Bug #67256
------------------------------------------------------------------------
[2017-05-09 13:57:50] schmidt@php.net
Description:
------------
According to the documentation, DateTimeZone::getLocation() returns an array.
However, it returns false when using an unnamed timezone. I would expect it to return an array with
dummy values similar to that returned for e.g. Etc/UTC+2.
See also bug 67256 about DateTimeZone::getTransitions().
Test script:
---------------
$dt = new DateTime('2017-01-01 12:00+00:00');
var_dump($dt->getTimezone()->getLocation());
Expected result:
----------------
array(4) {
["country_code"]=>
string(2) "??"
["latitude"]=>
float(0)
["longitude"]=>
float(0)
["comments"]=>
string(0) ""
}
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74562&edit=1