Display number of days rather than hours if >72h

This commit is contained in:
TwiN 2021-11-08 20:57:58 -05:00
parent 5e711fb3b9
commit a0ec6941ab

View File

@ -2,7 +2,11 @@ export const helper = {
methods: { methods: {
generatePrettyTimeAgo(t) { generatePrettyTimeAgo(t) {
let differenceInMs = new Date().getTime() - new Date(t).getTime(); 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); let hours = (differenceInMs / 3600000).toFixed(0);
return hours + " hour" + (hours !== "1" ? "s" : "") + " ago"; return hours + " hour" + (hours !== "1" ? "s" : "") + " ago";
} }