Req #73988 [Wfx]: zone offset not recognized by timezone_name_from_abbr

From: Date: Wed, 25 Jan 2017 11:20:57 +0000
Subject: Req #73988 [Wfx]: zone offset not recognized by timezone_name_from_abbr
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206941@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73988&edit=1 ID: 73988 Updated by: derick@php.net Reported by: cca dot alexk at gmail dot com Summary: zone offset not recognized by timezone_name_from_abbr Status: Wont fix Type: Feature/Change Request Package: Date/time related Operating System: MacOS/Linux PHP Version: 7.0.15 Block user comment: N Private report: N New Comment: @requinix@php.net — yes, we can remove the use of the fallback map, but not in any released branch as it would be a BC break. Also note that changes to timelib need to go to https://github.com/derickr/timelib — PHP isn't the only user of this library. Previous Comments: ------------------------------------------------------------------------ [2017-01-25 08:33:15] cca dot alexk at gmail dot com Changed expected timezone to "Asia/Novosibirsk" in PR. ------------------------------------------------------------------------ [2017-01-24 18:12:45] requinix@php.net Related: isdst=-1 is not supported for the fallback search. https://3v4l.org/coVcm @derick: Can the search be rewritten to work with just the main timelib_timezone_lookup map? I'm too lazy to make a patch or PR for this (let alone test it) but I'm thinking like https://gist.github.com/requinix/dffeb6a11b278182901cd277bc5b6ba8 And I don't see anything else using timelib_timezone_fallbackmap/fallbackmap.h so they could go away. ------------------------------------------------------------------------ [2017-01-24 18:02:06] cca dot alexk at gmail dot com As for the naming of zone is up to you. For me important only valid result from function. What language capabilities I can to use for maping offset to zonename? Of course I can build my own map, but it's better to use PHP capabilities for me. ------------------------------------------------------------------------ [2017-01-24 17:46:07] derick@php.net Guessing the timezone identifier from just an abbreviation + UTCoffset + DSTenabled, is a tricky thing to do at first, as a combination is not unique. It is even trickier to do with *just* UTCoffset + DSTenabled. The fallback map was only really implemented to keep function parity with old PHP versions. At the time when it was written, there was no timezone that used UTC+6 (without DST), and hence, it does not have an entry. Right now for example, there could be several equally correct pickings: derick@whisky:~ $ for i in /usr/share/zoneinfo/Asia/*; do zdump -v $i -c 2013,2018 |grep "isdst=0 gmtoff=21600"; done /usr/share/zoneinfo/Asia/Barnaul Sat Oct 25 19:00:00 2014 UT = Sun Oct 26 01:00:00 2014 +06 isdst=0 gmtoff=21600 /usr/share/zoneinfo/Asia/Barnaul Sat Mar 26 19:59:59 2016 UT = Sun Mar 27 01:59:59 2016 +06 isdst=0 gmtoff=21600 /usr/share/zoneinfo/Asia/Novosibirsk Sat Oct 25 19:00:00 2014 UT = Sun Oct 26 01:00:00 2014 NOVT isdst=0 gmtoff=21600 /usr/share/zoneinfo/Asia/Omsk Sat Oct 25 19:00:00 2014 UT = Sun Oct 26 01:00:00 2014 OMST isdst=0 gmtoff=21600 /usr/share/zoneinfo/Asia/Tomsk Sat Oct 25 19:00:00 2014 UT = Sun Oct 26 01:00:00 2014 +06 isdst=0 gmtoff=21600 /usr/share/zoneinfo/Asia/Tomsk Sat May 28 19:59:59 2016 UT = Sun May 29 01:59:59 2016 +06 isdst=0 gmtoff=21600 /usr/share/zoneinfo/Asia/Yekaterinburg Sat Oct 25 19:59:59 2014 UT = Sun Oct 26 01:59:59 2014 YEKT isdst=0 gmtoff=21600 I am reluctant to add more entries to this fallback map, and even if we would add it, I think it should be added as: { "novt", 0, 360, "Asia/Novosibirsk" }, To fit in with: { "novst", 1, 420, "Asia/Novosibirsk" }, { "krat", 0, 420, "Asia/Krasnoyarsk" }, { "krast", 1, 480, "Asia/Krasnoyarsk" }, Because of the non-uniqueness, I am not in favour in adding more entries. ------------------------------------------------------------------------ [2017-01-24 17:24:17] cca dot alexk at gmail dot com Description: ------------ timezone_name_from_abbr return false on valid time offset. For example: Asia/Omsk has GMT+6(MSK+3) timezone, but function return false. Test script: --------------- var_dump( timezone_name_from_abbr("", 6*3600, false) ); Expected result: ---------------- Timezone string "Asia/Omsk" Actual result: -------------- false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73988&edit=1

« previous php.bugs (#206941) next »