From 1079962e4c06f88a54e50d997c1b7e84303d30b4 Mon Sep 17 00:00:00 2001 From: Bernhard Schmidt Date: Sat, 15 Aug 2020 21:29:50 +0200 Subject: New upstream version 2.5~beta1 --- src/openvpn/otime.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/openvpn/otime.c') diff --git a/src/openvpn/otime.c b/src/openvpn/otime.c index 805aac9..640168a 100644 --- a/src/openvpn/otime.c +++ b/src/openvpn/otime.c @@ -88,9 +88,9 @@ const char * tv_string(const struct timeval *tv, struct gc_arena *gc) { struct buffer out = alloc_buf_gc(64, gc); - buf_printf(&out, "[%d/%d]", - (int) tv->tv_sec, - (int )tv->tv_usec); + buf_printf(&out, "[%" PRIi64 "/%ld]", + (int64_t)tv->tv_sec, + (long)tv->tv_usec); return BSTR(&out); } @@ -103,7 +103,7 @@ const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc) { return time_string((time_t) tv->tv_sec, - (int) tv->tv_usec, + (long) tv->tv_usec, true, gc); } @@ -127,12 +127,15 @@ time_string(time_t t, int usec, bool show_usec, struct gc_arena *gc) } t = tv.tv_sec; - buf_printf(&out, "%s", ctime(&t)); - buf_rmtail(&out, '\n'); + struct tm *tm = localtime(&t); + + buf_printf(&out, "%04d-%02d-%02d %02d:%02d:%02d", + tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); if (show_usec && tv.tv_usec) { - buf_printf(&out, " us=%d", (int)tv.tv_usec); + buf_printf(&out, " us=%ld", (long)tv.tv_usec); } return BSTR(&out); @@ -198,10 +201,10 @@ time_test(void) t = time(NULL); gettimeofday(&tv, NULL); #if 1 - msg(M_INFO, "t=%u s=%u us=%u", - (unsigned int)t, - (unsigned int)tv.tv_sec, - (unsigned int)tv.tv_usec); + msg(M_INFO, "t=%" PRIi64 " s=%" PRIi64 " us=%ld", + (int64_t)t, + (int64_t)tv.tv_sec, + (long)tv.tv_usec); #endif } } -- cgit v1.2.3