about summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-14 17:10:28 -0500
committerJune McEnroe <june@causal.agency>2019-11-14 17:10:28 -0500
commit474de83b4dab1668b83c133435e5896ee002b6af (patch)
tree5a02a34810d1dccaf6b56ea5b7770421a551e1b3 /client.c
parentRemove server-time filter TODO (diff)
downloadpounce-474de83b4dab1668b83c133435e5896ee002b6af.tar.gz
pounce-474de83b4dab1668b83c133435e5896ee002b6af.zip
Use struct timeval for sub-second precision
Diffstat (limited to '')
-rw-r--r--client.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/client.c b/client.c
index de3f087..3dce5e9 100644
--- a/client.c
+++ b/client.c
@@ -19,6 +19,7 @@
 #include <regex.h>
 #include <stdarg.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -394,7 +395,7 @@ static Filter *Filters[] = {
 };
 
 void clientConsume(struct Client *client) {
-	time_t time;
+	struct timeval time;
 	const char *line = ringPeek(&time, client->consumer);
 	if (!line) return;
 
@@ -409,10 +410,13 @@ void clientConsume(struct Client *client) {
 	}
 
 	if (client->caps & CapServerTime) {
-		char ts[sizeof("YYYY-MM-DDThh:mm:ss.sssZ")];
-		struct tm *tm = gmtime(&time);
-		strftime(ts, sizeof(ts), "%FT%T.000Z", tm);
-		clientFormat(client, "@time=%s %s\r\n", ts, line);
+		char ts[sizeof("YYYY-MM-DDThh:mm:ss")];
+		struct tm *tm = gmtime(&time.tv_sec);
+		strftime(ts, sizeof(ts), "%FT%T", tm);
+		clientFormat(
+			client, "@time=%s.%03jdZ %s\r\n",
+			ts, (intmax_t)(time.tv_usec / 1000), line
+		);
 	} else {
 		clientFormat(client, "%s\r\n", line);
 	}