diff --git a/builtin.c b/builtin.c index d7b2337..239a258 100644 --- a/builtin.c +++ b/builtin.c @@ -2096,6 +2096,8 @@ do_systime(int nargs ATTRIBUTE_UNUSED) return make_number((AWKNUM) lclock); } +#ifndef HAVE_TIMEGM + /* mktime_tz --- based on Linux timegm man page */ static time_t @@ -2124,6 +2126,14 @@ mktime_tz(struct tm *tm, const char *tzreq) return ret; } +static inline time_t +timegm(struct tm *tm) +{ + return mktime_tz(tm, "UTC+0"); +} + +#endif /* HAVE_TIMEGM */ + /* do_mktime --- turn a time string into a timestamp */ NODE * @@ -2184,7 +2194,7 @@ do_mktime(int nargs) then.tm_year = year - 1900; then.tm_isdst = dst; - then_stamp = (do_gmt ? mktime_tz(& then, "UTC+0") : mktime(& then)); + then_stamp = (do_gmt ? timegm(& then) : mktime(& then)); return make_number((AWKNUM) then_stamp); } diff --git a/configure.ac b/configure.ac index c6c7e50..bbc87b9 100644 --- a/configure.ac +++ b/configure.ac @@ -312,7 +312,7 @@ AC_CHECK_FUNCS(__etoa_l atexit btowc fmod gai_strerror \ memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \ snprintf strchr \ strerror strftime strcasecmp strncasecmp strcoll strtod strtoul \ - system tmpfile towlower towupper tzset usleep waitpid wcrtomb \ + system timegm tmpfile towlower towupper tzset usleep waitpid wcrtomb \ wcscoll wctype) dnl this check is for both mbrtowc and the mbstate_t type, which is good AC_FUNC_MBRTOWC