Improvements for display #1

Merged
norbert.tretkowski merged 11 commits from max.lissowski/mastowall:for-pi2 into for-pi2 2023-11-24 07:53:19 +01:00
Showing only changes of commit df73c736dd - Show all commits

View file

@ -17,20 +17,32 @@ const secondsAgo = date => Math.floor((new Date() - date) / 1000);
const timeAgo = function(seconds) {
// An array of intervals for years, months, days, hours, and minutes.
const intervals = [
{ limit: 31536000, text: 'Jahren' },
{ limit: 2592000, text: 'Monaten' },
{ limit: 86400, text: 'Tagen' },
{ limit: 3600, text: 'Stunden' },
{ limit: 60, text: 'Minuten' }
{ limit: 31536000, singular: 'Jahre', plural: 'Jahren' },
{ limit: 2592000, singular: 'Monat', plural: 'Monaten' },
{ limit: 86400, singular: 'Tag', plural: 'Tagen' },
{ limit: 3600, singular: 'Stunde', plural: 'Stunden' },
{ limit: 60, singular: 'Minute', plural: 'Minuten' }
];
// Loop through the intervals to find which one is the best fit.
for (let interval of intervals) {
if (seconds >= interval.limit) {
return "Vor " + Math.floor(seconds / interval.limit) + ` ${interval.text}`;
let amount = Math.floor(seconds / interval.limit);
let text;
if (amount !== 1) {
text = interval.plural;
} else {
text = interval.singular;
}
return `Vor ${amount} ${text}`;
}
}
return "Vor " + Math.floor(seconds) + " Sekunden";
let text = "Sekunde";
let amount = Math.floor(seconds);
if (amount !== 1) {
text += "n";
}
return `Vor ${amount} ${text}`;
};
let includeReplies;