Skip to content

Fix getTimezoneOffset() when tm_gmtoff is not available #224

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

Merged
merged 19 commits into from
Dec 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
#define CONFIG_PRINTF_RNDN
#endif

#if defined(__NEWLIB__)
#define NO_TM_GMTOFF
#endif

/* dump object free */
//#define DUMP_FREE
//#define DUMP_CLOSURE
Expand Down Expand Up @@ -40524,7 +40528,17 @@ static int getTimezoneOffset(int64_t time) {
}
ti = time;
localtime_r(&ti, &tm);
#ifdef NO_TM_GMTOFF
struct tm gmt;
gmtime_r(&ti, &gmt);

/* disable DST adjustment on the local tm struct */
tm.tm_isdst = 0;

return difftime(mktime(&gmt), mktime(&tm)) / 60;
#else
return -tm.tm_gmtoff / 60;
#endif /* NO_TM_GMTOFF */
#endif
}

Expand Down