summaryrefslogtreecommitdiff
path: root/src/openvpn/otime.c
diff options
context:
space:
mode:
authorBernhard Schmidt <berni@debian.org>2020-08-15 21:29:50 +0200
committerBernhard Schmidt <berni@debian.org>2020-08-15 21:29:50 +0200
commit1079962e4c06f88a54e50d997c1b7e84303d30b4 (patch)
tree4d019426928435425214ccedd6f89b70dbdf035d /src/openvpn/otime.c
parent620785fe268a1221c1ba7a9cb5a70f3140a4f1ca (diff)
New upstream version 2.5~beta1upstream/2.5_beta1
Diffstat (limited to 'src/openvpn/otime.c')
-rw-r--r--src/openvpn/otime.c25
1 files changed, 14 insertions, 11 deletions
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
}
}