From d6a2c9ed4b01c9d7da101db051b5dfe7c4282835 Mon Sep 17 00:00:00 2001 From: TheRealJan Date: Thu, 21 Sep 2023 22:01:24 +0200 Subject: [PATCH] Fix task showing "tomorrow" when its "today" --- .../java/io/github/jan/kex/ui/components/SubjectCard.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/jan/kex/ui/components/SubjectCard.kt b/app/src/main/java/io/github/jan/kex/ui/components/SubjectCard.kt index 0888437..87f6cb0 100644 --- a/app/src/main/java/io/github/jan/kex/ui/components/SubjectCard.kt +++ b/app/src/main/java/io/github/jan/kex/ui/components/SubjectCard.kt @@ -51,4 +51,9 @@ fun SubjectCard( } } -val Task.daysUntil get(): Long = (dueDate - Clock.System.now()).inWholeDays + 1 \ No newline at end of file +val Task.daysUntil get(): Long { + val difference = (dueDate - Clock.System.now()) + val days = difference.inWholeDays + val hours = difference.inWholeHours + return if(hours < 0L) 0 else days + 1 +} \ No newline at end of file