Skip to content

Commit fbe9266

Browse files
committedJun 14, 2022
8288378: [BACKOUT] DST not applying properly with zone id offset set with TZ env variable
Reviewed-by: dholmes
1 parent 1904353 commit fbe9266

File tree

2 files changed

+4
-94
lines changed

2 files changed

+4
-94
lines changed
 

‎src/java.base/unix/native/libjava/TimeZone_md.c

+4-17
Original file line numberDiff line numberDiff line change
@@ -592,31 +592,18 @@ getGMTOffsetID()
592592
{
593593
time_t offset;
594594
char sign, buf[32];
595-
struct tm localtm;
596-
time_t clock;
597-
598-
clock = time(NULL);
599-
if (localtime_r(&clock, &localtm) == NULL) {
600-
return strdup("GMT");
601-
}
602-
603-
struct tm gmt;
604-
605-
if (gmtime_r(&clock, &gmt) == NULL) {
606-
return strdup("GMT");
607-
}
608-
609-
offset = (localtm.tm_hour - gmt.tm_hour)*3600 + (localtm.tm_min - gmt.tm_min)*60;
595+
offset = timezone;
610596

611597
if (offset == 0) {
612598
return strdup("GMT");
613599
}
614600

601+
/* Note that the time offset direction is opposite. */
615602
if (offset > 0) {
616-
sign = '+';
603+
sign = '-';
617604
} else {
618605
offset = -offset;
619-
sign = '-';
606+
sign = '+';
620607
}
621608
sprintf(buf, (const char *)"GMT%c%02d:%02d",
622609
sign, (int)(offset/3600), (int)((offset%3600)/60));

‎test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java

-77
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.