From a0ec6941ab3c13112d31a9720b2d9b43544f460a Mon Sep 17 00:00:00 2001 From: TwiN Date: Mon, 8 Nov 2021 20:57:58 -0500 Subject: [PATCH] Display number of days rather than hours if >72h --- web/app/src/mixins/helper.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/app/src/mixins/helper.js b/web/app/src/mixins/helper.js index 71f56d2a..6b96b64d 100644 --- a/web/app/src/mixins/helper.js +++ b/web/app/src/mixins/helper.js @@ -2,7 +2,11 @@ export const helper = { methods: { generatePrettyTimeAgo(t) { let differenceInMs = new Date().getTime() - new Date(t).getTime(); - if (differenceInMs > 3600000) { + if (differenceInMs > 3*86400000) { // If it was more than 3 days ago, we'll display the number of days ago + let days = (differenceInMs / 86400000).toFixed(0); + return days + " day" + (days !== "1" ? "s" : "") + " ago"; + } + if (differenceInMs > 3600000) { // If it was more than 1h ago, display the number of hours ago let hours = (differenceInMs / 3600000).toFixed(0); return hours + " hour" + (hours !== "1" ? "s" : "") + " ago"; }