From fa80a2b56c4d501a2f648425d611554c6ee34372 Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Wed, 24 Jan 2024 09:40:30 +0100
Subject: Mention durations in tooltips on publications.html
---
 resources/pug/finals/publications.pug | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
(limited to 'resources')
diff --git a/resources/pug/finals/publications.pug b/resources/pug/finals/publications.pug
index 2de2fc1..d35fe08 100644
--- a/resources/pug/finals/publications.pug
+++ b/resources/pug/finals/publications.pug
@@ -123,7 +123,17 @@ block content
 					staticScale: 25,
 				},
 				tooltip: {
-					xDateFormat: '%Y-%m-%d',
+					pointFormatter: function () {
+						const start = this.series.chart.time.dateFormat('%Y-%m-%d', this.start);
+
+						if (!this.end) { /* milestone */
+							return `${this.name} on ${start}`;
+						}
+
+						const days = Math.floor((this.end - this.start) / 1000 / 60 / 60 / 24);
+						const end = this.series.chart.time.dateFormat('%Y-%m-%d', this.end);
+						return `In ${this.name} for ${days} days; ${start}–${end}`;
+					},
 				},
 				series,
 			});
-- 
cgit v1.2.3