Fix: Format entire frontend properly

This commit is contained in:
Daniel Hougaard
2024-03-18 16:00:03 +01:00
parent 1ede551c3e
commit 9002e6cb33
230 changed files with 2752 additions and 2941 deletions
+7 -9
View File
@@ -4,32 +4,30 @@
* @returns {String} text - how much time has passed since a certain timestamp
*/
function timeSince(date: Date) {
const seconds = Math.floor(
((new Date() as any) - (date as any)) / 1000
) as number;
const seconds = Math.floor(((new Date() as any) - (date as any)) / 1000) as number;
let interval = seconds / 31536000;
if (interval > 1) {
return `${Math.floor(interval) } years ago`;
return `${Math.floor(interval)} years ago`;
}
interval = seconds / 2592000;
if (interval > 1) {
return `${Math.floor(interval) } months ago`;
return `${Math.floor(interval)} months ago`;
}
interval = seconds / 86400;
if (interval > 1) {
return `${Math.floor(interval) } days ago`;
return `${Math.floor(interval)} days ago`;
}
interval = seconds / 3600;
if (interval > 1) {
return `${Math.floor(interval) } hours ago`;
return `${Math.floor(interval)} hours ago`;
}
interval = seconds / 60;
if (interval > 1) {
return `${Math.floor(interval) } minutes ago`;
return `${Math.floor(interval)} minutes ago`;
}
return `${Math.floor(seconds) } seconds ago`;
return `${Math.floor(seconds)} seconds ago`;
}
export default timeSince;