Skip to content

Time zone offset for Win32 #290

@afulsamet

Description

@afulsamet

Patch to get current time zone offset for Win32. GetTimeZoneInformation: Retrieves the current time zone of the active machine, check remarks to see formula.

The bias is the difference, in minutes, between UTC time and local time.

diff --git a/quickjs.c b/quickjs.c
index c6efc21..fadde4a 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -40827,8 +40827,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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions