Skip to content

Windows: Date() ignores timezome #325

@avih

Description

@avih

This happens both when building (and testing) in MSYS2 (mingw), and when cross-building using debian's mingw (and testing on windows) as described at #324 .

In GMT+2 zone on Windows, at the REPL:

> Date()
"Mon Nov 21 2022 07:56:51 GMT+0000"

While on linux with the same timezone, this prints:

> Date()
"Mon Nov 21 2022 10:00:12 GMT+0200"

I think this also causes a test failure at tests/test-ffi.js. I modified the ffi test like so (after it failed the hour and dst comparisons):

diff --git a/tests/test-ffi.js b/tests/test-ffi.js
index 6899dd9..2ce94e4 100644
--- a/tests/test-ffi.js
+++ b/tests/test-ffi.js
@@ -137,6 +137,7 @@ const FFI = tjs.ffi;
                assert.eq(tm.year, 122); // years since 1900
                assert.eq(tm.mon, 6); // month since January, 0-11
                const cmpDate = new Date(testTimestamp*1000);
+                throw(Error(["ffi time:", JSON.stringify(tm), "js time:", cmpDate]));
                assert.eq(tm.mday, cmpDate.getDate()); // day of the month, 1-31
                assert.eq(tm.hour, cmpDate.getHours()); // hours since midnight, 0-23
                assert.eq(tm.min, cmpDate.getMinutes()); // minutes after the hour, 0-59

And it prints (hour +3, dst differ):

Error: ffi time:,{"sec":27,"min":16,"hour":15,"mday":20,"mon":6,"year":122,"wday":3,"yday":200,"isdst":1},js time:,Wed Jul 20 2022 12:16:27 GMT+0000

I also tried setting TZ=... and it did not seem to affect the js Date() value, but it did seem to affect the ffi localtime value (hour +1,dst differ):

Error: ffi time:,{"sec":27,"min":16,"hour":13,"mday":20,"mon":6,"year":122,"wday":3,"yday":200,"isdst":1},js time:,Wed Jul 20 2022 12:16:27 GMT+0000

I'm guessing this is a quickjs issue? (but googling did not seem to find it mentioned anywhere).

(edited few times with more accurate info/outputs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions