more precision

This commit is contained in:
Benjamin Wilson
2024-08-22 10:46:10 -04:00
parent 74f9d2e8c4
commit c3149e2965

View File

@@ -22,12 +22,14 @@ export class DateAgoPipe implements PipeTransform {
}; };
let counter; let counter;
for (const i in intervals) { for (const i in intervals) {
const number = (seconds / intervals[i]).toFixed(1);
counter = Math.floor(seconds / intervals[i]); counter = Math.floor(seconds / intervals[i]);
if (counter > 0) if (counter > 0)
if (counter === 1) { if (counter === 1) {
return counter + ' ' + i + ''; // singular (1 day ago) return number + ' ' + i + ''; // singular (1 day ago)
} else { } else {
return counter + ' ' + i + 's'; // plural (2 days ago) return number + ' ' + i + 's'; // plural (2 days ago)
} }
} }
} }