Skip to content

Commit d11f5f6

Browse files
authored
Implement getTimezoneOffset for Win32 (#291)
Retrieves the current time zone settings with GetTimeZoneInformation to calculate time zone offset
1 parent 708dbcb commit d11f5f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

quickjs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include <assert.h>
3333
#if !defined(_MSC_VER)
3434
#include <sys/time.h>
35+
#if defined(_WIN32)
36+
#include <timezoneapi.h>
37+
#endif
3538
#endif
3639
#include <time.h>
3740
#include <fenv.h>
@@ -40827,8 +40830,9 @@ static const JSCFunctionListEntry js_math_obj[] = {
4082740830
between UTC time and local time 'd' in minutes */
4082840831
static int getTimezoneOffset(int64_t time) {
4082940832
#if defined(_WIN32)
40830-
/* XXX: TODO */
40831-
return 0;
40833+
TIME_ZONE_INFORMATION time_zone_info;
40834+
GetTimeZoneInformation(&time_zone_info);
40835+
return (int)time_zone_info.Bias / 60;
4083240836
#else
4083340837
time_t ti;
4083440838
struct tm tm;

0 commit comments

Comments
 (0)