Req #81083 [Opn->Fbk]: Another way to get timezone by timeoffset from current one

From: Date: Wed, 26 May 2021 19:23:47 +0000
Subject: Req #81083 [Opn->Fbk]: Another way to get timezone by timeoffset from current one
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234033@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81083&edit=1

 ID:                 81083
 Updated by:         requinix@php.net
 Reported by:        6562680 at gmail dot com
-Summary:            [ SUGGESTION ] Another way to get timezone by
                     timeoffset from current one
+Summary:            Another way to get timezone by timeoffset from
                     current one
-Status:             Open
+Status:             Feedback
 Type:               Feature/Change Request
 Package:            Date/time related
 Operating System:   Win10
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Not sure I follow.

You can already get a list of timezones with DateTimeZone::listIdentifiers() + new DateTimeZone. You
can then filter that list with getOffset(the desired time).
It's pretty easy: https://3v4l.org/MTfj6

If there's one bit of room for improvement there, I'd have listIdentifiers optionally
return objects instead of strings. (Or create a new method to do that.)

Stuff with coordinates (a) doesn't belong in the PHP core, not least because timezonedb is not
part of PHP, and (b) doesn't even make sense because timezones are logically north-south
"strips" of the planet, and the timezone "cities" used as identifiers are merely
prominent locations chosen according to the rules they follow(ed) for DST transitions.


Previous Comments:
------------------------------------------------------------------------
[2021-05-26 19:01:57] 6562680 at gmail dot com

Description:
------------
If you add main geopoint in lat/lng into abbreviations list we have to sort list by diff from
current one to get shortest line.

Example: you are in London (UTC). You want to get closest timezone for your clients that tell you
they have +3 hours from you.

You write function like getTzOffset(int), call it like getTzOffset(5) - there you should iterate
over all abbreviations.

Trying to sort result cities list could become Africa/Madagaskar (first because of alphabetical
order), but i hope your clients is somewhere in Europe...

Once we have lat/lng of main point of hour line we can sort by x/y difference to get closest one.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81083&edit=1


Thread (3 messages)

« previous php.bugs (#234033) next »