From d11f5f600df87b5f2c9f3d59856c31c3d8cc2a36 Mon Sep 17 00:00:00 2001 From: Aful Date: Sun, 3 Mar 2024 18:23:48 +0300 Subject: [PATCH] Implement getTimezoneOffset for Win32 (#291) Retrieves the current time zone settings with GetTimeZoneInformation to calculate time zone offset --- quickjs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quickjs.c b/quickjs.c index c6efc21..97db3bc 100644 --- a/quickjs.c +++ b/quickjs.c @@ -32,6 +32,9 @@ #include #if !defined(_MSC_VER) #include +#if defined(_WIN32) +#include +#endif #endif #include #include @@ -40827,8 +40830,9 @@ static const JSCFunctionListEntry js_math_obj[] = { between UTC time and local time 'd' in minutes */ static int getTimezoneOffset(int64_t time) { #if defined(_WIN32) - /* XXX: TODO */ - return 0; + TIME_ZONE_INFORMATION time_zone_info; + GetTimeZoneInformation(&time_zone_info); + return (int)time_zone_info.Bias / 60; #else time_t ti; struct tm tm;