From 94f2a93ebb107af976a80b93b95737a498b552b2 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Fri, 2 Dec 2022 17:09:37 +0100 Subject: [PATCH] fix TODO --- app/src/frontend/building/data-containers/planning.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/frontend/building/data-containers/planning.tsx b/app/src/frontend/building/data-containers/planning.tsx index 7a38cdc1..20e046c7 100644 --- a/app/src/frontend/building/data-containers/planning.tsx +++ b/app/src/frontend/building/data-containers/planning.tsx @@ -25,8 +25,10 @@ const currentYear = new Date().getFullYear(); const currentTimestamp = new Date().valueOf(); const milisecondsInYear = 1000 * 60 * 60 * 24 * 365; -// TODO: there is already "parseDate" in helpers -function parseDate(isoUtcDate: string): Date { +// there is already "parseDate" in helpers +// but it is using timestamp as input, while this one +// uses lower accuracy (as actual data is using the same accuracy) +function parseDateSpecifiedWithDailyAccuracy(isoUtcDate: string): Date { const [year, month, day] = isoUtcDate.match(/^(\d{4})-(\d\d)-(\d\d)$/) .splice(1) .map(x => parseInt(x, 10)); @@ -36,12 +38,12 @@ function parseDate(isoUtcDate: string): Date { function isArchived(item) { const decisionDate = item.decision_date; if(decisionDate != null) { - if ((currentTimestamp - parseDate(decisionDate).valueOf()) > milisecondsInYear) { + if ((currentTimestamp - parseDateSpecifiedWithDailyAccuracy(decisionDate).valueOf()) > milisecondsInYear) { return true; } } if(item.registered_with_local_authority_date != null) { - if ((currentTimestamp - parseDate(item.registered_with_local_authority_date).valueOf()) > milisecondsInYear) { + if ((currentTimestamp - parseDateSpecifiedWithDailyAccuracy(item.registered_with_local_authority_date).valueOf()) > milisecondsInYear) { return true; } }