From 9b1ef90207eb50b7527e650093505952329e5f92 Mon Sep 17 00:00:00 2001 From: Arif Hasanic Date: Wed, 12 Aug 2026 10:15:27 +0200 Subject: [PATCH] fix dateime for positive dates, add new color and new text for chore due today --- src/components/Flatastic/Flatastic.tsx | 22 +++++++++++++++------- src/components/Flatastic/style.module.css | 5 +++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/components/Flatastic/Flatastic.tsx b/src/components/Flatastic/Flatastic.tsx index 1768594..4469873 100644 --- a/src/components/Flatastic/Flatastic.tsx +++ b/src/components/Flatastic/Flatastic.tsx @@ -15,20 +15,28 @@ function choreItem(chore: FlatasticChore, idToNameMap: Record) { if (chore.rotationTime === -1) { className = "irregular"; } else { - className = chore.timeLeftNext <= 0 ? "due" : "notDue"; + const negativeTimeFix = chore.timeLeftNext < 0 ? 1 : 0; // Floats are rounded down, so we need to add 1 to the days if the time is negative + const timeInDays = + Math.abs(chore.timeLeftNext) / (60 * 60 * 24) + negativeTimeFix; - const timeInDays = Math.abs(chore.timeLeftNext) / (60 * 60 * 24) + 1; - const grubers = Math.floor(timeInDays / 100); - const days = Math.floor(timeInDays % 100); + const bigG = Math.trunc(timeInDays / 100); + const days = Math.trunc(timeInDays % 100); timeLeftInDays = ( - {grubers > 0 && `${grubers} g${grubers > 1 ? "s" : ""} `} - {days > 0 && `${days} d`} + {bigG > 0 && `${bigG} g${bigG > 1 ? "s" : ""} `} + {days >= 0 && `${days} d`} ); - Math.abs(chore.timeLeftNext) / (60 * 60 * 24) + 1; + if (days === 0) { + className = "dueToday"; + timeLeftInDays = today; + } else if (chore.timeLeftNext < 0) { + className = "due"; + } else { + className = "notDue"; + } } return ( diff --git a/src/components/Flatastic/style.module.css b/src/components/Flatastic/style.module.css index 52f4702..33fc8ef 100644 --- a/src/components/Flatastic/style.module.css +++ b/src/components/Flatastic/style.module.css @@ -66,6 +66,11 @@ background-color: #a6cfa6; } +/* oragne redis color */ +.dueToday { + background-color: #eda455; +} + .timeLeft { font-weight: bold; }