ICUTimeConversion: Handle GMT properly in _FillTmValues.

We can be called with a timezone that isn't the same as the one
set in the current locale, in particular from gmtime(). We thus need
to handle this case properly by checking that the gmtoff is really
the timezone in the locale, or if it's GMT, to just use a static
string for the tm_zone instead.

Fixes #19047.
This commit is contained in:
Augustin Cavalier 2024-09-03 12:51:59 -04:00
parent 6b468e5635
commit 5b4d5ef897

View File

@ -246,7 +246,14 @@ ICUTimeConversion::_FillTmValues(const TimeZone* icuTimeZone,
+ calendar.get(UCAL_DST_OFFSET, icuStatus)) / 1000;
if (!U_SUCCESS(icuStatus))
return B_ERROR;
tmOut->tm_zone = fDataBridge->addrOfTZName[tmOut->tm_isdst ? 1 : 0];
if (tmOut->tm_gmtoff == -*fDataBridge->addrOfTimezone) {
tmOut->tm_zone = fDataBridge->addrOfTZName[tmOut->tm_isdst ? 1 : 0];
} else if (tmOut->tm_gmtoff == 0) {
tmOut->tm_zone = (char*)"GMT";
} else {
return B_ERROR;
}
return B_OK;
}