summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--html.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/html.c b/html.c
index eefb6e7..7975aab 100644
--- a/html.c
+++ b/html.c
@@ -178,17 +178,20 @@ enum kcgi_err htmlFooter(struct khtmlreq *html) {
 		|| khtml_closeto(html, 0);
 }
 
-static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) {
-	char time[sizeof("0000-00-00 00:00:00")];
-	strftime(time, sizeof(time), "%F %T", gmtime(&event.time));
+static const char *timestamp(time_t time) {
+	static char stamp[sizeof("0000-00-00 00:00:00")];
+	strftime(stamp, sizeof(stamp), "%F %T", gmtime(&time));
+	return stamp;
+}
 
+static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) {
 	char *base = NULL;
 	if (event.network && event.context) {
 		base = khttp_urlpart(
 			NULL, NULL, Pages[Events],
 			Keys[Network].name, event.network,
 			Keys[Context].name, event.context,
-			Keys[After].name, time,
+			Keys[After].name, timestamp(event.time - eventsOverlap),
 			NULL
 		);
 		if (!base) err(EX_OSERR, "khttp_urlpart");
@@ -201,8 +204,12 @@ static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) {
 	enum kcgi_err error = 0
 		|| khtml_attr(html, KELEM_TD, KATTR_CLASS, "time", KATTR__MAX)
 		|| khtml_attr(html, KELEM_A, KATTR_HREF, href, KATTR__MAX)
-		|| khtml_attr(html, KELEM_TIME, KATTR_DATETIME, time, KATTR__MAX)
-		|| khtml_puts(html, time)
+		|| khtml_attr(
+			html, KELEM_TIME,
+			KATTR_DATETIME, timestamp(event.time),
+			KATTR__MAX
+		)
+		|| khtml_puts(html, timestamp(event.time))
 		|| khtml_closeelem(html, 3);
 
 	free(href);