Fix getTimezoneOffset()
when tm_gmtoff
is not available (#224)
This commit is contained in:
parent
2fb838c803
commit
440fc1b96b
1 changed files with 14 additions and 0 deletions
14
quickjs.c
14
quickjs.c
|
@ -60,6 +60,10 @@
|
||||||
#define CONFIG_PRINTF_RNDN
|
#define CONFIG_PRINTF_RNDN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__NEWLIB__)
|
||||||
|
#define NO_TM_GMTOFF
|
||||||
|
#endif
|
||||||
|
|
||||||
/* dump object free */
|
/* dump object free */
|
||||||
//#define DUMP_FREE
|
//#define DUMP_FREE
|
||||||
//#define DUMP_CLOSURE
|
//#define DUMP_CLOSURE
|
||||||
|
@ -40685,7 +40689,17 @@ static int getTimezoneOffset(int64_t time) {
|
||||||
}
|
}
|
||||||
ti = time;
|
ti = time;
|
||||||
localtime_r(&ti, &tm);
|
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;
|
return -tm.tm_gmtoff / 60;
|
||||||
|
#endif /* NO_TM_GMTOFF */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue