fix dateime for positive dates, add new color and new text for chore due today
CI / build (push) Failing after 15s
CI / lint (push) Skipped
CI / create-and-publish-docker-image (push) Skipped

This commit is contained in:
2026-08-12 10:15:27 +02:00
parent baa926e47a
commit 9b1ef90207
2 changed files with 20 additions and 7 deletions
+15 -7
View File
@@ -15,20 +15,28 @@ function choreItem(chore: FlatasticChore, idToNameMap: Record<number, string>) {
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 = (
<span className={style.timeLeft}>
{grubers > 0 && `${grubers} g${grubers > 1 ? "s" : ""} `}
{days > 0 && `${days} d`}
{bigG > 0 && `${bigG} g${bigG > 1 ? "s" : ""} `}
{days >= 0 && `${days} d`}
</span>
);
Math.abs(chore.timeLeftNext) / (60 * 60 * 24) + 1;
if (days === 0) {
className = "dueToday";
timeLeftInDays = <span className={style.timeLeft}>today</span>;
} else if (chore.timeLeftNext < 0) {
className = "due";
} else {
className = "notDue";
}
}
return (
@@ -66,6 +66,11 @@
background-color: #a6cfa6;
}
/* oragne redis color */
.dueToday {
background-color: #eda455;
}
.timeLeft {
font-weight: bold;
}