From c3149e29657487c0debe73d095ad546d5df53f0a Mon Sep 17 00:00:00 2001 From: Benjamin Wilson Date: Thu, 22 Aug 2024 10:46:10 -0400 Subject: [PATCH] more precision --- src/app/pipes/date-ago.pipe.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/pipes/date-ago.pipe.ts b/src/app/pipes/date-ago.pipe.ts index 62e236c..2283c63 100644 --- a/src/app/pipes/date-ago.pipe.ts +++ b/src/app/pipes/date-ago.pipe.ts @@ -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) } } }