<i18n dev> RFR: 8285838: DST not applying properly with zone id offset set with TZ env variable
Naoto Sato
naoto at openjdk.java.net
Tue May 17 20:48:55 UTC 2022
On Wed, 11 May 2022 18:00:31 GMT, Gaurav Chaudhari <duke at openjdk.java.net> wrote:
> This fix ensures that when a lookup for a custom TZ code fails, and an attempt is made to find the GMT offset in order to get the current time, Daylight savings rules are applied correctly.
Thanks for contributing the fix. This issue has been reported in the past, but closed as will not fix (https://bugs.openjdk.java.net/browse/JDK-6992725), as implementing POSIX TZ fully requires a sizable amount of work for a rare situation. Returning a fixed offset ID with the `TZ` set to observing DST is thus a compromised solution. Even if the fix would return a custom zone observing the DST does not mean the zone is correct in winter. Having said that I agree that the derived fixed offset zone should reflect the *current* offset, as well as macOS's implementation.
src/java.base/unix/native/libjava/TimeZone_md.c line 609:
> 607: }
> 608:
> 609: offset = (gmt.tm_hour - localtm.tm_hour)*3600 + (gmt.tm_min - localtm.tm_min)*60;
Since it is not using `timezone` anymore, we can reverse the subtraction, i.e., `localtime` - `gmtime` so that the weird sign switch below can be eliminated.
test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java line 2:
> 1: /*
> 2: * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
This is a new test case, the year should be only 2022.
test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java line 27:
> 25: * Specifically called by runCustomTzIDCheckDST.sh to check if Daylight savings is
> 26: * properly followed with a custom TZ code set through environment variables.
> 27: * */
Nit: Need a new line.
test/jdk/java/util/TimeZone/runCustomTzIDCheckDST.sh line 1:
> 1: #
I'd change this script into a java test case (using `.sh` is not recommended). In fact, this causes a failure invoking `javac` with `-Xmx768m` (from TESTVMOPTS)
There are libraries under `jdk/test/lib/` for building test jvm process and tools.
test/jdk/java/util/TimeZone/runCustomTzIDCheckDST.sh line 40:
> 38:
> 39: OS=`uname -s`
> 40: case "$OS" in
In case other than Linux/AIX, it would be helpful to emit some message that the test is ignored.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8661
More information about the i18n-dev
mailing list