From 175c1d537db8500d353dad72ca48cd6e8d1e9d2d Mon Sep 17 00:00:00 2001 From: C4illin Date: Fri, 3 May 2024 20:58:22 +0200 Subject: [PATCH] fix easter logic maybe --- lasvecka-node/calc_date.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lasvecka-node/calc_date.js b/lasvecka-node/calc_date.js index b36df43..fb43a19 100644 --- a/lasvecka-node/calc_date.js +++ b/lasvecka-node/calc_date.js @@ -34,6 +34,7 @@ function readDatePeriod(currDate) { ) { continue; } + const deltaT = moment(dat).diff(currDate, "days"); if (deltaT === 0) { return { date: dat, type: dateDict[dat] }; @@ -47,13 +48,13 @@ function readDatePeriod(currDate) { return { date: soughtDate, type: dateDict[soughtDate] }; } -function handleEaster(easterStartDiff, easterEndDiff) { - if (easterStartDiff >= 0 && easterEndDiff <= 0) { +function handleEaster(easterStartCheck, easterEndCheck) { + if (easterStartCheck >= 0 && easterEndCheck <= 0) { return "Självstudier"; } - if (easterEndDiff > 0) { - const weeks = Math.floor(easterEndDiff / 7); - return `Lv ${weeks + 4}`; + if (easterEndCheck > 0) { + const weeks = Math.floor(easterEndCheck / 7); + return `Lv ${weeks + 3}`; } }