Skip to content

Commit 53b641d

Browse files
committed
Fixes timezone bias on Windows
`GetTimeZoneInformation`returns the bias in minutes already, so no need to adjust it. Also handle the return code since it determines if the time zone is in the daylight saving range. Ref: https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation Fixes: saghul/txiki.js#325
1 parent 66732e7 commit 53b641d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

quickjs.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -43386,9 +43386,14 @@ static const JSCFunctionListEntry js_math_obj[] = {
4338643386
between UTC time and local time 'd' in minutes */
4338743387
static int getTimezoneOffset(int64_t time) {
4338843388
#if defined(_WIN32)
43389-
TIME_ZONE_INFORMATION time_zone_info;
43390-
GetTimeZoneInformation(&time_zone_info);
43391-
return (int)time_zone_info.Bias / 60;
43389+
DWORD r;
43390+
TIME_ZONE_INFORMATION t;
43391+
r = GetTimeZoneInformation(&t);
43392+
if (r == TIME_ZONE_ID_INVALID)
43393+
return 0;
43394+
if (r == TIME_ZONE_ID_DAYLIGHT)
43395+
return (int)(t.Bias + t.DaylightBias);
43396+
return (int)t.Bias;
4339243397
#else
4339343398
time_t ti;
4339443399
struct tm tm;

0 commit comments

Comments
 (0)