From: Olaf Wintermann Date: Fri, 5 Jun 2026 09:10:58 +0000 (+0200) Subject: fix difference in behavior between item cleanup and item age filter X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=3d42e6df6400cf1c000e4c61c322aac07f447864;p=rssreader.git fix difference in behavior between item cleanup and item age filter --- diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/SyncJob.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/SyncJob.kt index 62506fe..6c9b70a 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/SyncJob.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/SyncJob.kt @@ -3,20 +3,17 @@ package de.unixwork.rssreader import com.rometools.rome.io.SyndFeedInput import com.rometools.rome.io.XmlReader import de.unixwork.ui.kotlin.ToolkitDispatcher -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.IO -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.* import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse -import java.time.Duration import java.time.Instant +import java.time.LocalDate +import java.time.ZoneId +import java.time.ZoneOffset +import java.time.temporal.ChronoUnit + class SyncJob(settings: Settings, feeds: () -> List) { val settings = settings @@ -65,6 +62,7 @@ class SyncJob(settings: Settings, feeds: () -> List) { val input = SyndFeedInput() val syndFeed = input.build(XmlReader(stream)) val items = mutableListOf() + val utcNow = Instant.now().atZone(ZoneOffset.UTC).toLocalDate() println("Fetched feed: ${syndFeed.title}") syndFeed.entries.forEach { entry -> //println(" ${entry.title} - ${entry.link}") @@ -73,7 +71,8 @@ class SyncJob(settings: Settings, feeds: () -> List) { if(max_age > 0) { val date = entry.updatedDate ?: entry.publishedDate date?.let { - val age = Duration.between(it.toInstant(), Instant.now()).toDays() + val localDate = it.toInstant().atZone(ZoneOffset.UTC).toLocalDate() + val age = ChronoUnit.DAYS.between(localDate,utcNow) if(age > max_age) { //println("Item too old, skipping: ${entry.title} date: ${it}") return@forEach