From 5c0a43e8d6e1f3fa920199c83fa6d8bd01d420ef Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 24 Mar 2022 18:49:00 -0400 Subject: [PATCH] Fix off by 1 dates (fixes #6791) --- .../eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt | 2 +- .../eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt | 2 +- .../main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt index 51025c1a48..1c03d5fd95 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt @@ -66,7 +66,7 @@ class HistoryPresenter : BasePresenter() { .map { recents -> val map = TreeMap> { d1, d2 -> d2.compareTo(d1) } val byDay = recents - .groupByTo(map, { it.history.last_read.toDateKey() }) + .groupByTo(map) { it.history.last_read.toDateKey() } byDay.flatMap { entry -> val dateItem = DateSectionItem(entry.key, relativeTime, dateFormat) entry.value.map { HistoryItem(it, dateItem) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt index f0c9b5369a..a22003a5a2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt @@ -84,7 +84,7 @@ class UpdatesPresenter : BasePresenter() { .map { mangaChapters -> val map = TreeMap> { d1, d2 -> d2.compareTo(d1) } val byDay = mangaChapters - .groupByTo(map, { it.chapter.date_fetch.toDateKey() }) + .groupByTo(map) { it.chapter.date_fetch.toDateKey() } byDay.flatMap { entry -> val dateItem = DateSectionItem(entry.key, relativeTime, dateFormat) entry.value diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt index f5c86a8fbd..33bf15dfd2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/DateExtensions.kt @@ -112,8 +112,8 @@ fun Date.toRelativeString( val days = difference.floorDiv(MILLISECONDS_IN_DAY).toInt() return when { difference < 0 -> context.getString(R.string.recently) - difference < MILLISECONDS_IN_DAY -> context.getString(R.string.relative_time_today) - difference < MILLISECONDS_IN_DAY.times(range) -> context.resources.getQuantityString( + difference <= MILLISECONDS_IN_DAY -> context.getString(R.string.relative_time_today) + difference <= MILLISECONDS_IN_DAY.times(range) -> context.resources.getQuantityString( R.plurals.relative_time, days, days