From: Alexander Gozman Date: Thu, 7 May 2015 09:40:28 +0000 (+0300) Subject: Add timezone to timestamp in JSON logs X-Git-Tag: suricata-2.1beta4~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b12c53cd51ca1b24039c248f1eab6808d9686e4b;p=thirdparty%2Fsuricata.git Add timezone to timestamp in JSON logs --- diff --git a/src/util-time.c b/src/util-time.c index 1e4237335d..7c7a362458 100644 --- a/src/util-time.c +++ b/src/util-time.c @@ -128,11 +128,11 @@ void CreateIsoTimeString (const struct timeval *ts, char *str, size_t size) time_t time = ts->tv_sec; struct tm local_tm; struct tm *t = (struct tm*)SCLocalTime(time, &local_tm); + char time_fmt[64] = { 0 }; if (likely(t != NULL)) { - snprintf(str, size, "%04d-%02d-%02dT%02d:%02d:%02d.%06u", - t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, - t->tm_min, t->tm_sec, (uint32_t) ts->tv_usec); + strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06u%z", t); + snprintf(str, size, time_fmt, ts->tv_usec); } else { snprintf(str, size, "ts-error"); }