Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Date() ignores timezome #325

Open
avih opened this issue Nov 21, 2022 · 2 comments
Open

Windows: Date() ignores timezome #325

avih opened this issue Nov 21, 2022 · 2 comments

Comments

@avih
Copy link

avih commented Nov 21, 2022

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)

@bnoordhuis
Copy link
Contributor

I didn't check the source code but it sounds like quickjs or txiki should be calling _tzset() during initialization.

@saghul
Copy link
Owner

saghul commented Nov 21, 2022

I didn't check the source code but it sounds like quickjs or txiki should be calling _tzset() during initialization.

Thanks Ben, I'll look into that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants