8288378: [BACKOUT] DST not applying properly with zone id offset set with TZ env variable

Reviewed-by: dholmes
This commit is contained in:
Naoto Sato 2022-06-14 01:06:54 +00:00
parent 19043538e1
commit fbe9266622
2 changed files with 4 additions and 94 deletions

View file

@ -592,31 +592,18 @@ getGMTOffsetID()
{
time_t offset;
char sign, buf[32];
struct tm localtm;
time_t clock;
clock = time(NULL);
if (localtime_r(&clock, &localtm) == NULL) {
return strdup("GMT");
}
struct tm gmt;
if (gmtime_r(&clock, &gmt) == NULL) {
return strdup("GMT");
}
offset = (localtm.tm_hour - gmt.tm_hour)*3600 + (localtm.tm_min - gmt.tm_min)*60;
offset = timezone;
if (offset == 0) {
return strdup("GMT");
}
/* Note that the time offset direction is opposite. */
if (offset > 0) {
sign = '+';
sign = '-';
} else {
offset = -offset;
sign = '-';
sign = '+';
}
sprintf(buf, (const char *)"GMT%c%02d:%02d",
sign, (int)(offset/3600), (int)((offset%3600)/60));