From a818a27f0f5bf001c212659c0a09247671056a08 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 23 Nov 2014 19:01:17 +0100 Subject: [PATCH] frontend/scanner: Fixed parsing of time values. It turns out, mktime() cannot be used to parse a time (at day 0). Let's do it manually then, it's no big magic anyway ;-) --- src/frontend/scanner.l | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/frontend/scanner.l b/src/frontend/scanner.l index f17b689..65ec9ed 100644 --- a/src/frontend/scanner.l +++ b/src/frontend/scanner.l @@ -210,6 +210,7 @@ time ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?) struct tm tm; char time[9], ns[10]; char *tmp; + int t; memset(&tm, 0, sizeof(tm)); memset(time, '\0', sizeof(time)); @@ -246,7 +247,8 @@ time ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?) return SCANNER_ERROR; } - yylval->datetime = SECS_TO_SDB_TIME(mktime(&tm)); + t = tm.tm_sec + 60 * tm.tm_min + 3600 * tm.tm_hour; + yylval->datetime = SECS_TO_SDB_TIME(t); yylval->datetime += (sdb_time_t)strtoll(ns, NULL, 10); return TIME; } -- 2.30.2