diff src/site.js @ 88:7b339b1ccd11

add tools/users.html
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 13 Mar 2025 16:18:39 -0600
parents dade6a560494
children
line wrap: on
line diff
--- a/src/site.js	Wed Mar 12 14:20:10 2025 -0600
+++ b/src/site.js	Thu Mar 13 16:18:39 2025 -0600
@@ -90,3 +90,35 @@
 function closeModal(el) {
 	getEnclosingDialog(el).close();
 }
+
+let times = [
+	{
+		time: 1000*60*60*24,
+		unit: 'day'
+	},
+	{
+		time: 1000*60*60,
+		unit: 'hour'
+	},
+	{
+		time: 1000*60,
+		unit: 'minute'
+	},
+	{
+		time: 1000,
+		unit: 'second'
+	}
+];
+
+function ago(time) {
+	for( let t of times ) {
+		let n = Math.floor(time / t.time);
+		if( n > 0 ) {
+			let s = `${n} ${t.unit}`;
+			if( n > 1 )
+				s = s + 's';
+			return s + ' ago';
+		}
+	}
+	return 'just now';
+}