mirror of
https://github.com/benjamin-wilson/public-pool-ui.git
synced 2025-03-17 13:22:55 +01:00
more precision
This commit is contained in:
parent
74f9d2e8c4
commit
c3149e2965
@ -22,12 +22,14 @@ export class DateAgoPipe implements PipeTransform {
|
||||
};
|
||||
let counter;
|
||||
for (const i in intervals) {
|
||||
const number = (seconds / intervals[i]).toFixed(1);
|
||||
counter = Math.floor(seconds / intervals[i]);
|
||||
|
||||
if (counter > 0)
|
||||
if (counter === 1) {
|
||||
return counter + ' ' + i + ''; // singular (1 day ago)
|
||||
return number + ' ' + i + ''; // singular (1 day ago)
|
||||
} else {
|
||||
return counter + ' ' + i + 's'; // plural (2 days ago)
|
||||
return number + ' ' + i + 's'; // plural (2 days ago)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user