[tz] Support for Etc/GMT -style zones ids with partial hours
Neil Fuller
nfuller at google.com
Wed Oct 21 18:45:33 UTC 2020
>
> How does that work at the user level? I have an Android 10 phone (build
> QQ1A.200105.032), and couldn't see these UI options under either
> "Settings>System>Date & time>Time zone" or "Clock>⋮>Settings>Home time
> zone"
> (these have different UIs).
>
Partners are free to replace / modify settings up to a point, but even in
the stock code the support for fixed offsets is *not* very obvious. This is
partly by design as it's a niche use case. In the top right corner usually
there's a menu button with a single item: "Select by UTC offset" which puts
the settings picker into a different mode.
It's the Settings that is considered part of the Android platform (where I
work). The Clock app is an app that operates on many versions of Android
and can be updated independently. As far as I know relies on the TZDB rules
provided by the platform but it ships with a list of the more common zones,
not a comprehensive list.
In GNU/Linux the way to solve this problem is to use a TZ setting like
> TZ='<+0545>-5:45' for Nepal (or TZ='NPT-5:45' for older POSIX). Does this
> work
> for Android? If so, I suggest going that way. If not, perhaps POSIX TZ
> support
> should be added to Android; that shouldn't be hard, and would improve
> functionality and compatibility in other areas too. If it couldn't be done
> for
> Android it could at least be done for the Clock app.
>
I know that wouldn't work today. I'm sorry to say it would also probably be
quite a lot more work than adding new entries to TZDB. The odds of Android
consistently supporting the newer POSIX free-form any time soon are
probably low. I'll try to explain...
In short, this is because Android uses a combination of various open source
libraries. There are a lot of history / compatibility considerations. i.e.
all the parts agree on what the TZDB identifiers mean, but probably not
more than that. I've seen a few pieces of fallback logic that first try to
treat a string as a TZDB identifier before falling back to other parsing
(but which differ). There's the extra dimension that 3rd party apps may
also be reading this information, and so existing apps and they libraries
they use may break when confronted with something in the
form '<+0545>-5:45' when they're expecting a TZDB identifier, or conform to
an older POSIX spec.
I know support for non-TZDB identifiers was explicitly removed before I
started working on Android. For example [3]:
* <p> On android M and above, it is an error to pass in a non-Olson
timezone to this
* function. Note that this is a bad idea on all Android releases because
POSIX and
* the {@code TimeZone} class have opposite interpretations of {@code '+'}
and {@code '-'}
* in the same non-Olson ID.
To be honest, just adding new "Etc/GMT-5:30" identifiers could also cause
problems (not just for Android), but it seems likely it could be made to
work without too much effort on the Android side. Even if there was
enthusiasm here, I would want to try it out and would need to consider the
effect on older releases of Android in case the colon character broke
something, or a widely used app out there would try to parse anything after
"GMT" as an integer!
Just for completeness: Android does not primarily use the TZ environment
variable: components like our libc and managed code have been altered to
refer to Android's system property libraries, which ensures that all
long-running programs are informed via events (AKA Intents on Android) when
the value changes. This ensures that the UI updates and that the various
APIs we expose to apps return a consistent answer regardless of when the
process started. This is similar to what happens when the user changes
their preferred language settings.
Neil.
[3]
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/app/AlarmManager.java#982
On Wed, 21 Oct 2020 at 18:50, Paul Eggert <eggert at cs.ucla.edu> wrote:
> On 10/21/20 10:12 AM, Neil Fuller via tz wrote:
> > The Stock Android settings UI, starting with Android Pie (9.0), allows
> > users to select from the fixed "Etc/GMT-5" style identifiers from TZDB
>
> How does that work at the user level? I have an Android 10 phone (build
> QQ1A.200105.032), and couldn't see these UI options under either
> "Settings>System>Date & time>Time zone" or "Clock>⋮>Settings>Home time
> zone"
> (these have different UIs).
>
> > The current Etc/GMT[+-] zone identifiers in TZDB only cover whole hour
> > offsets. There are various places that use 30 minute offsets, and a few
> > that use 45/15 minute offsets [2].
>
> I suppose we could add IDs for non-hour offsets currently in use. I worry,
> though, that there will be more odd offsets outside the civil-aviation
> application area, such as the offsets that various astronomical
> observatories
> use (as Steve Allen mentioned).
>
> In GNU/Linux the way to solve this problem is to use a TZ setting like
> TZ='<+0545>-5:45' for Nepal (or TZ='NPT-5:45' for older POSIX). Does this
> work
> for Android? If so, I suggest going that way. If not, perhaps POSIX TZ
> support
> should be added to Android; that shouldn't be hard, and would improve
> functionality and compatibility in other areas too. If it couldn't be done
> for
> Android it could at least be done for the Clock app.
>
--
Google UK Limited
Registered Office: 6 Pancras Square, London, N1C 4AG
Registered in England Number: 3977902
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mm.icann.org/pipermail/tz/attachments/20201021/6b93586a/attachment.htm>
More information about the tz
mailing list