backdrop-contrib / timezone_detect

Auto-detect and set user timezones in Backdrop.
GNU General Public License v2.0
0 stars 0 forks source link

Not always able to match timezones #3

Open jenlampton opened 3 years ago

jenlampton commented 3 years ago

I've found that the time zone detect library isn't always able to match timezones in browsers to those in Backdrop. It struggles with some US midwest locations, and many in South America. I don't know if the problem is the format of what's in the browser, or the format of what's in Backdrop, but there are definitely mismatches.

Here are a few examples from my dblog:

laryn commented 3 years ago

I'm not sure if this is helpful but posting here for future reference. RE: time zone detection in Client Side Date Field Formatter by @indigoxela:

No library at all, not timezone handling in any way, super lazy - I let the browser decide.

That only needs minimal js code: https://github.com/backdrop-contrib/cs_date_formatter/blob/1.x-1.x/js/cs-date-formatter.js

kswan commented 1 year ago

I noticed similar errors in my dblog. For example:

Investigating, I found that timezone_detect checks the value received from the browser against the PHP function timezone_identifiers_list(). https://github.com/backdrop-contrib/timezone_detect/blob/a2edeec6061e48d548495c9c89364d7d647efc10/timezone_detect.module#L119-L124 timezone_identifiers_list() doesn't include the timezones Jen listed as well as the timezones I see.

Apparently, the Etc/GMT*, America/Buenos_Aires, and America/Indianapolis timezones are deprecated, but still sent by browsers.

timezone_identifiers_list() offers an option to include deprecated time zones in this format: timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)

Adding timezone_identifiers_list(DateTimeZone::ALL_WITH_BC) to the valid timezone check would probably cause later problems because the user account would show a timezone that isn't recognized by the rest of backdrop.

laryn commented 1 year ago

Anybody want to write a little function to try to convert a deprecated timezone to a current one, as a last ditch effort before failing?

laryn commented 1 year ago

Not much traction on this issue recently, but: https://github.com/pellepim/jstimezonedetect/issues/12