aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/js/timeago.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/static/js/timeago.ts b/static/js/timeago.ts
index 6e56063..af974fc 100644
--- a/static/js/timeago.ts
+++ b/static/js/timeago.ts
@@ -21,10 +21,19 @@
const hours: number = Math.floor(minutes / 60);
const days: number = Math.floor(hours / 24);
- if (seconds <= 60) { return element.textContent = relative.format(-1 * seconds, "second",); }
- if (minutes <= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
- if (hours <= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
- if (days <= 60) { return element.textContent = relative.format(-1 * days, "day",); }
+ if (Math.sign(seconds) === 1) {
+ if (seconds <= 60) { return element.textContent = relative.format(-1 * seconds, "second",); }
+ if (minutes <= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
+ if (hours <= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
+ if (days <= 60) { return element.textContent = relative.format(-1 * days, "day",); }
+ }
+
+ if (Math.sign(seconds) === -1) {
+ if (-1 * days >= 60) { return element.textContent = relative.format(-1 * days, "day",); }
+ if (-1 * hours >= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
+ if (-1 * minutes >= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
+ if (-1 * seconds >= 0) { return element.textContent = relative.format(-1 * seconds, "second",); }
+ }
} catch (error) {
console.error(