aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cutils.c14
-rw-r--r--vl.c2
-rw-r--r--vl.h1
3 files changed, 16 insertions, 1 deletions
diff --git a/cutils.c b/cutils.c
index 074b5acd47..7836a3e994 100644
--- a/cutils.c
+++ b/cutils.c
@@ -81,3 +81,17 @@ int stristart(const char *str, const char *val, const char **ptr)
*ptr = p;
return 1;
}
+
+time_t mktimegm(struct tm *tm)
+{
+ time_t t;
+ int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
+ if (m < 3) {
+ m += 12;
+ y--;
+ }
+ t = 86400 * (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 +
+ y / 400 - 719469);
+ t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
+ return t;
+}
diff --git a/vl.c b/vl.c
index e70ed4c31d..d1ae8cab95 100644
--- a/vl.c
+++ b/vl.c
@@ -8116,7 +8116,7 @@ int main(int argc, char **argv)
}
tm.tm_year -= 1900;
tm.tm_mon--;
- rtc_start_date = timegm(&tm);
+ rtc_start_date = mktimegm(&tm);
if (rtc_start_date == -1) {
date_fail:
fprintf(stderr, "Invalid date format. Valid format are:\n"
diff --git a/vl.h b/vl.h
index 099bbb7ad4..047fd3bbb5 100644
--- a/vl.h
+++ b/vl.h
@@ -123,6 +123,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
+time_t mktimegm(struct tm *tm);
/* vl.c */
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);