From e27495c6241785604413de6c43d92d55ab462564 Mon Sep 17 00:00:00 2001 From: Achintya-Chatterjee Date: Thu, 11 Jul 2024 16:14:10 +0530 Subject: [PATCH] fix:wrong eta --- app/helpers/convertDate.js | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/app/helpers/convertDate.js b/app/helpers/convertDate.js index 316f4985..e7e235c9 100644 --- a/app/helpers/convertDate.js +++ b/app/helpers/convertDate.js @@ -7,10 +7,10 @@ const timeDifference = (timestamp, timeNow) => { const mins = calc(60, timeInSec); const hours = calc(60, mins); const days = calc(24, hours); - const weeks = Math.floor(days / 7); - const remainingDays = days % 7; - const months = calc(30, days); - const years = calc(12, months); + const months = Math.floor(days / 30); + const years = Math.floor(months / 12); + + console.log({ timeInSec, mins, hours, days, months, years }); // Debug log if (timeInSec < 1) { return { result: '', cycle: 'just now' }; @@ -20,16 +20,6 @@ const timeDifference = (timestamp, timeNow) => { return { result: years, cycle: 'year' }; } else if (months > 0) { return { result: months, cycle: 'month' }; - } else if (weeks > 0) { - if (remainingDays > 0) { - return { - result: weeks, - cycle: 'week', - extra: remainingDays, - extraCycle: 'day', - }; - } - return { result: weeks, cycle: 'week' }; } else if (days > 0) { return { result: days, cycle: 'day' }; } else if (hours > 0) { @@ -49,12 +39,6 @@ function convertDate([timestamp], { end_date, timeNow = Date.now() }) { time_value.result > 1 ? 's' : '' }`; - if (time_value.extra) { - timeString += ` and ${time_value.extra} ${time_value.extraCycle}${ - time_value.extra > 1 ? 's' : '' - }`; - } - if (end_date == 1 && timestamp * 1000 < timeNow) { return `${timeString} ago`; }