Edit report at http://bugs.php.net/bug.php?id=51975&edit=1
ID: 51975
User updated by: V-o-E at gmx dot de
Reported by: V-o-E at gmx dot de
Summary: Missing DST free (UTC±X) timezones in
DateTimeZone::listIdentifiers()
Status: Bogus
Type: Bug
Package: Date/time related
Operating System: All
PHP Version: 5.3.2
New Comment:
oh, i see.
# We use POSIX-style signs in the Zone names and the output
abbreviations,
# even though this is the opposite of what many people expect.
# POSIX has positive signs west of Greenwich, but many people expect
# positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses
# the abbreviation "GMT+4" and corresponds to 4 hours behind UTC
# (i.e. west of Greenwich) even though many people would expect it to
# mean 4 hours ahead of UTC (i.e. east of Greenwich).
#
# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation
# (which is not yet supported by the tz code) allows for
# TZ='<GMT-4>+4'; if you want time zone abbreviations conforming to
# ISO 8601 you can use TZ='<-0400>+4'. Thus the commonly-expected
# offset is kept within the angle bracket (and is used for display)
# while the POSIX sign is kept outside the angle bracket (and is used
# for calculation).
#
# Do not use a TZ setting like TZ='GMT+4', which is four hours behind
# GMT but uses the completely misleading abbreviation "GMT".
# Earlier incarnations of this package were not POSIX-compliant,
# and had lines such as
# Zone GMT-12 -12 - GMT-1200
# We did not want things to change quietly if someone accustomed to the
old
# way does a
# zic -l GMT-12
# so we moved the names into the Etc subdirectory.
Zone Etc/GMT-14 14 - GMT-14 # 14 hours ahead of GMT
Zone Etc/GMT-13 13 - GMT-13
Zone Etc/GMT-12 12 - GMT-12
Zone Etc/GMT-11 11 - GMT-11
Zone Etc/GMT-10 10 - GMT-10
Zone Etc/GMT-9 9 - GMT-9
Zone Etc/GMT-8 8 - GMT-8
Zone Etc/GMT-7 7 - GMT-7
Zone Etc/GMT-6 6 - GMT-6
Zone Etc/GMT-5 5 - GMT-5
Zone Etc/GMT-4 4 - GMT-4
Zone Etc/GMT-3 3 - GMT-3
Zone Etc/GMT-2 2 - GMT-2
Zone Etc/GMT-1 1 - GMT-1
Zone Etc/GMT+1 -1 - GMT+1
Zone Etc/GMT+2 -2 - GMT+2
Zone Etc/GMT+3 -3 - GMT+3
Zone Etc/GMT+4 -4 - GMT+4
Zone Etc/GMT+5 -5 - GMT+5
Zone Etc/GMT+6 -6 - GMT+6
Zone Etc/GMT+7 -7 - GMT+7
Zone Etc/GMT+8 -8 - GMT+8
Zone Etc/GMT+9 -9 - GMT+9
Zone Etc/GMT+10 -10 - GMT+10
Zone Etc/GMT+11 -11 - GMT+11
Zone Etc/GMT+12 -12 - GMT+12
This is output of "etcetera" file from "Olson tz database".
It is not deprecated, isn't it?
This are the "Etc*" zones from "backward" file:
Link Etc/GMT GMT+0
Link Etc/GMT GMT-0
Link Etc/GMT GMT0
Link Etc/GMT Greenwich
Link Etc/UCT UCT
Link Etc/UTC UTC
Link Etc/UTC Universal
Link Etc/UTC Zulu
So i think the "Etc/GMT±x" timezones from "etcetera" should be in
output of:
DateTimeZone::listIdentifiers()
DateTimeZone::listIdentifiers(DateTimeZone::ALL)
DateTimeZone::listIdentifiers(DateTimeZone::UTC)
and not only in:
DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC)
what is your opinion?
Previous Comments:
------------------------------------------------------------------------
[2010-06-02 15:41:15] [email protected]
The Olson tz database -- which forms the basis of the time zone support
both for PHP and pretty much every operating system not called Windows
-- doesn't define any time zones relative to UTC other than the
Etc/GMT±x time zones and the UTC time zone itself.
The Etc/GMT time zones are the "wrong way around", but that's been the
case for decades, and isn't something we (or probably anyone else) can
fix without confusing people even more.
------------------------------------------------------------------------
[2010-06-02 15:27:44] V-o-E at gmx dot de
Description:
------------
There are not daylight saving time free timezones (UTC±X) in
DateTimeZone::listIdentifiers() (same with DateTimeZone::ALL) except
UTC±0.
As workaround i can use buggy "Etc/GMT±X" from
DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC):
Etc/GMT+2 => Etc/GMT-2
Etc/GMT-2 => Etc/GMT+2
See: http://en.wikipedia.org/wiki/List_of_time_zones_by_UTC_offset
Test script:
---------------
var_dump(DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC));
var_dump(DateTimeZone::listIdentifiers());
$a = DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC);
var_dump($a[373]); // output: string(9) "Etc/GMT+2"
$b = DateTimeZone::listIdentifiers();
var_dump($b[373]); // output: string(15) "Pacific/Fakaofo"
date_default_timezone_set('UTC');
echo date('H:i:s') . "\n"; // output: 13:13:01
date_default_timezone_set('Etc/GMT+2');
echo date('H:i:s') . "\n"; // output: 11:13:01
date_default_timezone_set('Etc/GMT-2');
echo date('H:i:s') . "\n"; // output: 15:13:01
date_default_timezone_set('Pacific/Fakaofo');
echo date('H:i:s') . "\n"; // output: 01:13:01
Expected result:
----------------
array(564) {
...
}
array(xyz) {
...
[405]=>
string(3) "UTC"
[406]=>
string(3) "UTC-12"
[407]=>
string(3) "UTC-11"
...
}
string(9) "Pacific/Fakaofo"
string(15) "Pacific/Fakaofo"
13:16:08
15:16:08
11:16:08
03:16:08
Actual result:
--------------
array(564) {
...
}
array(406) {
...
[405]=>
string(3) "UTC"
}
string(9) "Etc/GMT+2"
string(15) "Pacific/Fakaofo"
13:16:08
11:16:08
15:16:08
03:16:08
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51975&edit=1