Skip to content

Commit a846975

Browse files
authored
Merge pull request #4471 from YoshiRulz/kotlify-datetime
Migrate to kotlinx-datetime
2 parents 33663cc + 5f7bc26 commit a846975

File tree

84 files changed

+369
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+369
-297
lines changed

app/build.gradle.kts

+3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ dependencies {
149149
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion")
150150
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$kotlinxCoroutinesVersion")
151151

152+
// Date/time
153+
api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
154+
152155
// scheduling background jobs
153156
implementation("androidx.work:work-runtime:2.7.1")
154157

app/src/androidTest/java/de/westnordost/streetcomplete/data/download/tiles/DownloadedTilesDaoTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.westnordost.streetcomplete.data.download.tiles
22

33
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
4+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
45
import org.junit.Assert.assertEquals
56
import org.junit.Assert.assertFalse
67
import org.junit.Assert.assertTrue
@@ -24,15 +25,15 @@ class DownloadedTilesDaoTest : ApplicationDbTestCase() {
2425

2526
@Test fun putGetOld() {
2627
dao.put(r(5, 8, 5, 8), "Huhu")
27-
val huhus = dao.get(r(5, 8, 5, 8), System.currentTimeMillis() + 1000)
28+
val huhus = dao.get(r(5, 8, 5, 8), nowAsEpochMilliseconds() + 1000)
2829
assertTrue(huhus.isEmpty())
2930
}
3031

3132
@Test fun putSomeOld() {
3233
dao.put(r(0, 0, 1, 3), "Huhu")
3334
Thread.sleep(2000)
3435
dao.put(r(1, 3, 5, 5), "Huhu")
35-
val huhus = dao.get(r(0, 0, 2, 2), System.currentTimeMillis() - 1000)
36+
val huhus = dao.get(r(0, 0, 2, 2), nowAsEpochMilliseconds() - 1000)
3637
assertTrue(huhus.isEmpty())
3738
}
3839

app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/mapdata/NodeDaoTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package de.westnordost.streetcomplete.data.osm.mapdata
22

33
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
44
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
5+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
56
import org.junit.Assert.assertEquals
67
import org.junit.Assert.assertFalse
78
import org.junit.Assert.assertNotNull
89
import org.junit.Assert.assertNull
910
import org.junit.Assert.assertTrue
1011
import org.junit.Before
1112
import org.junit.Test
12-
import java.lang.System.currentTimeMillis
1313

1414
class NodeDaoTest : ApplicationDbTestCase() {
1515
private lateinit var dao: NodeDao
@@ -76,13 +76,13 @@ class NodeDaoTest : ApplicationDbTestCase() {
7676

7777
@Test fun getUnusedAndOldIds() {
7878
dao.putAll(listOf(nd(1L), nd(2L), nd(3L)))
79-
val unusedIds = dao.getIdsOlderThan(currentTimeMillis() + 10)
79+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10)
8080
assertTrue(unusedIds.containsExactlyInAnyOrder(listOf(1L, 2L, 3L)))
8181
}
8282

8383
@Test fun getUnusedAndOldIdsButAtMostX() {
8484
dao.putAll(listOf(nd(1L), nd(2L), nd(3L)))
85-
val unusedIds = dao.getIdsOlderThan(currentTimeMillis() + 10, 2)
85+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10, 2)
8686
assertEquals(2, unusedIds.size)
8787
}
8888

app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/mapdata/RelationDaoTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.NODE
55
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.RELATION
66
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType.WAY
77
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
8+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
89
import org.junit.Assert.assertEquals
910
import org.junit.Assert.assertFalse
1011
import org.junit.Assert.assertNotNull
@@ -148,13 +149,13 @@ class RelationDaoTest : ApplicationDbTestCase() {
148149

149150
@Test fun getUnusedAndOldIds() {
150151
dao.putAll(listOf(rel(1L), rel(2L), rel(3L)))
151-
val unusedIds = dao.getIdsOlderThan(System.currentTimeMillis() + 10)
152+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10)
152153
assertTrue(unusedIds.containsExactlyInAnyOrder(listOf(1L, 2L, 3L)))
153154
}
154155

155156
@Test fun getUnusedAndOldIdsButAtMostX() {
156157
dao.putAll(listOf(rel(1L), rel(2L), rel(3L)))
157-
val unusedIds = dao.getIdsOlderThan(System.currentTimeMillis() + 10, 2)
158+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10, 2)
158159
assertEquals(2, unusedIds.size)
159160
}
160161

app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/mapdata/WayDaoTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package de.westnordost.streetcomplete.data.osm.mapdata
22

33
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
44
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
5+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
56
import org.junit.Assert.assertEquals
67
import org.junit.Assert.assertFalse
78
import org.junit.Assert.assertNotNull
@@ -103,13 +104,13 @@ class WayDaoTest : ApplicationDbTestCase() {
103104

104105
@Test fun getUnusedAndOldIds() {
105106
dao.putAll(listOf(way(1L), way(2L), way(3L)))
106-
val unusedIds = dao.getIdsOlderThan(System.currentTimeMillis() + 10)
107+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10)
107108
assertTrue(unusedIds.containsExactlyInAnyOrder(listOf(1L, 2L, 3L)))
108109
}
109110

110111
@Test fun getUnusedAndOldIdsButAtMostX() {
111112
dao.putAll(listOf(way(1L), way(2L), way(3L)))
112-
val unusedIds = dao.getIdsOlderThan(System.currentTimeMillis() + 10, 2)
113+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10, 2)
113114
assertEquals(2, unusedIds.size)
114115
}
115116

app/src/androidTest/java/de/westnordost/streetcomplete/data/osm/osmquests/OsmQuestsHiddenDaoTest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import de.westnordost.streetcomplete.data.ApplicationDbTestCase
44
import de.westnordost.streetcomplete.data.osm.mapdata.ElementType
55
import de.westnordost.streetcomplete.data.quest.OsmQuestKey
66
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
7+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
78
import kotlinx.coroutines.delay
89
import kotlinx.coroutines.runBlocking
910
import org.junit.Assert.assertEquals
@@ -44,7 +45,7 @@ class OsmQuestsHiddenDaoTest : ApplicationDbTestCase() {
4445
)
4546
dao.add(keys[0])
4647
delay(200)
47-
val time = System.currentTimeMillis()
48+
val time = nowAsEpochMilliseconds()
4849
dao.add(keys[1])
4950
val result = dao.getNewerThan(time - 100).single()
5051
assertEquals(keys[1], result.osmQuestKey)

app/src/androidTest/java/de/westnordost/streetcomplete/data/osmnotes/NoteDaoTest.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import de.westnordost.streetcomplete.data.osm.mapdata.BoundingBox
55
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
66
import de.westnordost.streetcomplete.data.user.User
77
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
8+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
89
import org.junit.Assert.assertEquals
910
import org.junit.Assert.assertFalse
1011
import org.junit.Assert.assertNotNull
@@ -101,13 +102,13 @@ class NoteDaoTest : ApplicationDbTestCase() {
101102

102103
@Test fun getUnusedAndOldIds() {
103104
dao.putAll(listOf(createNote(1), createNote(2), createNote(3)))
104-
val unusedIds = dao.getIdsOlderThan(System.currentTimeMillis() + 10)
105+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10)
105106
assertTrue(unusedIds.containsExactlyInAnyOrder(listOf(1L, 2L, 3L)))
106107
}
107108

108109
@Test fun getUnusedAndOldIdsButAtMostX() {
109110
dao.putAll(listOf(createNote(1), createNote(2), createNote(3)))
110-
val unusedIds = dao.getIdsOlderThan(System.currentTimeMillis() + 10, 2)
111+
val unusedIds = dao.getIdsOlderThan(nowAsEpochMilliseconds() + 10, 2)
111112
assertEquals(2, unusedIds.size)
112113
}
113114

app/src/androidTest/java/de/westnordost/streetcomplete/data/osmnotes/notequests/NoteQuestsHiddenDaoTest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package de.westnordost.streetcomplete.data.osmnotes.notequests
22

33
import de.westnordost.streetcomplete.data.ApplicationDbTestCase
44
import de.westnordost.streetcomplete.util.ktx.containsExactlyInAnyOrder
5+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
56
import kotlinx.coroutines.delay
67
import kotlinx.coroutines.runBlocking
78
import org.junit.Assert.assertEquals
@@ -42,7 +43,7 @@ class NoteQuestsHiddenDaoTest : ApplicationDbTestCase() {
4243
@Test fun getNewerThan() = runBlocking {
4344
dao.add(1L)
4445
delay(200)
45-
val time = System.currentTimeMillis()
46+
val time = nowAsEpochMilliseconds()
4647
dao.add(2L)
4748
val result = dao.getNewerThan(time - 100).single()
4849
assertEquals(2L, result.noteId)

app/src/main/java/de/westnordost/streetcomplete/StreetCompleteApplication.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import de.westnordost.streetcomplete.util.CrashReportExceptionHandler
4848
import de.westnordost.streetcomplete.util.getSelectedLocale
4949
import de.westnordost.streetcomplete.util.getSystemLocales
5050
import de.westnordost.streetcomplete.util.ktx.addedToFront
51+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
5152
import de.westnordost.streetcomplete.util.setDefaultLocales
5253
import kotlinx.coroutines.CoroutineName
5354
import kotlinx.coroutines.CoroutineScope
@@ -58,7 +59,6 @@ import org.koin.android.ext.android.inject
5859
import org.koin.android.ext.koin.androidContext
5960
import org.koin.androidx.workmanager.koin.workManagerFactory
6061
import org.koin.core.context.startKoin
61-
import java.lang.System.currentTimeMillis
6262
import java.util.concurrent.TimeUnit
6363

6464
class StreetCompleteApplication : Application() {
@@ -131,7 +131,7 @@ class StreetCompleteApplication : Application() {
131131

132132
applicationScope.launch {
133133
preloader.preload()
134-
editHistoryController.deleteSyncedOlderThan(currentTimeMillis() - ApplicationConstants.MAX_UNDO_HISTORY_AGE)
134+
editHistoryController.deleteSyncedOlderThan(nowAsEpochMilliseconds() - ApplicationConstants.MAX_UNDO_HISTORY_AGE)
135135
}
136136

137137
enqueuePeriodicCleanupWork()

app/src/main/java/de/westnordost/streetcomplete/data/Cleaner.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import de.westnordost.streetcomplete.data.osm.mapdata.MapDataController
66
import de.westnordost.streetcomplete.data.osmnotes.NoteController
77
import de.westnordost.streetcomplete.data.quest.QuestTypeRegistry
88
import de.westnordost.streetcomplete.util.ktx.format
9-
import java.lang.System.currentTimeMillis
9+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
1010

1111
/** Deletes old unused data in the background */
1212
class Cleaner(
@@ -15,15 +15,15 @@ class Cleaner(
1515
private val questTypeRegistry: QuestTypeRegistry
1616
) {
1717
fun clean() {
18-
val time = currentTimeMillis()
18+
val time = nowAsEpochMilliseconds()
1919

20-
val oldDataTimestamp = currentTimeMillis() - ApplicationConstants.DELETE_OLD_DATA_AFTER
20+
val oldDataTimestamp = nowAsEpochMilliseconds() - ApplicationConstants.DELETE_OLD_DATA_AFTER
2121
noteController.deleteOlderThan(oldDataTimestamp, MAX_DELETE_ELEMENTS)
2222
mapDataController.deleteOlderThan(oldDataTimestamp, MAX_DELETE_ELEMENTS)
2323
/* do this after cleaning map data and notes, because some metadata rely on map data */
2424
questTypeRegistry.forEach { it.deleteMetadataOlderThan(oldDataTimestamp) }
2525

26-
Log.i(TAG, "Cleaning took ${((currentTimeMillis() - time) / 1000.0).format(1)}s")
26+
Log.i(TAG, "Cleaning took ${((nowAsEpochMilliseconds() - time) / 1000.0).format(1)}s")
2727
}
2828

2929
companion object {

app/src/main/java/de/westnordost/streetcomplete/data/Preloader.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import android.util.Log
44
import de.westnordost.countryboundaries.CountryBoundaries
55
import de.westnordost.osmfeatures.FeatureDictionary
66
import de.westnordost.streetcomplete.util.ktx.format
7+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
78
import kotlinx.coroutines.Dispatchers
89
import kotlinx.coroutines.coroutineScope
910
import kotlinx.coroutines.launch
1011
import kotlinx.coroutines.withContext
11-
import java.lang.System.currentTimeMillis
1212
import java.util.concurrent.FutureTask
1313

1414
/** Initialize certain singleton classes used elsewhere throughout the app in the background */
@@ -18,7 +18,7 @@ class Preloader(
1818
) {
1919

2020
suspend fun preload() {
21-
val time = currentTimeMillis()
21+
val time = nowAsEpochMilliseconds()
2222
coroutineScope {
2323
// country boundaries are necessary latest for when a quest is opened or on a download
2424
launch { preloadCountryBoundaries() }
@@ -27,20 +27,20 @@ class Preloader(
2727
launch { preloadFeatureDictionary() }
2828
}
2929

30-
Log.i(TAG, "Preloading data took ${((currentTimeMillis() - time) / 1000.0).format(1)}s")
30+
Log.i(TAG, "Preloading data took ${((nowAsEpochMilliseconds() - time) / 1000.0).format(1)}s")
3131
}
3232

3333
private suspend fun preloadFeatureDictionary() = withContext(Dispatchers.IO) {
34-
val time = currentTimeMillis()
34+
val time = nowAsEpochMilliseconds()
3535
featuresDictionaryFuture.run()
36-
val seconds = (currentTimeMillis() - time) / 1000.0
36+
val seconds = (nowAsEpochMilliseconds() - time) / 1000.0
3737
Log.i(TAG, "Loaded features dictionary in ${seconds.format(1)}s")
3838
}
3939

4040
private suspend fun preloadCountryBoundaries() = withContext(Dispatchers.IO) {
41-
val time = currentTimeMillis()
41+
val time = nowAsEpochMilliseconds()
4242
countryBoundariesFuture.run()
43-
val seconds = (currentTimeMillis() - time) / 1000.0
43+
val seconds = (nowAsEpochMilliseconds() - time) / 1000.0
4444
Log.i(TAG, "Loaded country boundaries in ${seconds.format(1)}s")
4545
}
4646

app/src/main/java/de/westnordost/streetcomplete/data/download/Downloader.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import de.westnordost.streetcomplete.data.maptiles.MapTilesDownloader
99
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataDownloader
1010
import de.westnordost.streetcomplete.data.osmnotes.NotesDownloader
1111
import de.westnordost.streetcomplete.util.ktx.format
12+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
1213
import de.westnordost.streetcomplete.util.math.area
1314
import kotlinx.coroutines.coroutineScope
1415
import kotlinx.coroutines.launch
1516
import kotlinx.coroutines.sync.Mutex
1617
import kotlinx.coroutines.sync.withLock
17-
import java.lang.System.currentTimeMillis
1818
import kotlin.math.max
1919

2020
/** Downloads all the things */
@@ -36,7 +36,7 @@ class Downloader(
3636
}
3737
Log.i(TAG, "Starting download ($sqkm km², bbox: $bboxString)")
3838

39-
val time = currentTimeMillis()
39+
val time = nowAsEpochMilliseconds()
4040

4141
mutex.withLock {
4242
coroutineScope {
@@ -48,13 +48,13 @@ class Downloader(
4848
}
4949
putDownloadedAlready(tiles)
5050

51-
val seconds = (currentTimeMillis() - time) / 1000.0
51+
val seconds = (nowAsEpochMilliseconds() - time) / 1000.0
5252
Log.i(TAG, "Finished download ($sqkm km², bbox: $bboxString) in ${seconds.format(1)}s")
5353
}
5454

5555
private fun hasDownloadedAlready(tiles: TilesRect): Boolean {
5656
val freshTime = ApplicationConstants.REFRESH_DATA_AFTER
57-
val ignoreOlderThan = max(0, currentTimeMillis() - freshTime)
57+
val ignoreOlderThan = max(0, nowAsEpochMilliseconds() - freshTime)
5858
return downloadedTilesDb.get(tiles, ignoreOlderThan).contains(DownloadedTilesType.ALL)
5959
}
6060

app/src/main/java/de/westnordost/streetcomplete/data/download/strategy/AVariableRadiusStrategy.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import de.westnordost.streetcomplete.data.download.tiles.enclosingTilesRect
1010
import de.westnordost.streetcomplete.data.osm.mapdata.BoundingBox
1111
import de.westnordost.streetcomplete.data.osm.mapdata.LatLon
1212
import de.westnordost.streetcomplete.data.osm.mapdata.MapDataController
13+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
1314
import de.westnordost.streetcomplete.util.math.area
1415
import de.westnordost.streetcomplete.util.math.enclosingBoundingBox
1516
import kotlinx.coroutines.Dispatchers
@@ -79,7 +80,7 @@ abstract class AVariableRadiusStrategy(
7980
/** return if data in the given tiles rect that hasn't been downloaded yet */
8081
private suspend fun hasMissingDataFor(tilesRect: TilesRect): Boolean {
8182
val dataExpirationTime = ApplicationConstants.REFRESH_DATA_AFTER
82-
val ignoreOlderThan = max(0, System.currentTimeMillis() - dataExpirationTime)
83+
val ignoreOlderThan = max(0, nowAsEpochMilliseconds() - dataExpirationTime)
8384
val downloadedTiles =
8485
withContext(Dispatchers.IO) { downloadedTilesDao.get(tilesRect, ignoreOlderThan) }
8586
return !downloadedTiles.contains(DownloadedTilesType.ALL)

app/src/main/java/de/westnordost/streetcomplete/data/download/tiles/DownloadedTilesDao.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import de.westnordost.streetcomplete.data.download.tiles.DownloadedTilesTable.Co
66
import de.westnordost.streetcomplete.data.download.tiles.DownloadedTilesTable.Columns.X
77
import de.westnordost.streetcomplete.data.download.tiles.DownloadedTilesTable.Columns.Y
88
import de.westnordost.streetcomplete.data.download.tiles.DownloadedTilesTable.NAME
9-
import java.lang.System.currentTimeMillis
9+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
1010

1111
/** Keeps info in which areas things have been downloaded already in a tile grid */
1212
class DownloadedTilesDao(private val db: Database) {
1313

1414
/** Persist that the given type has been downloaded in every tile in the given tile range */
1515
fun put(tilesRect: TilesRect, typeName: String) {
16-
val time = currentTimeMillis()
16+
val time = nowAsEpochMilliseconds()
1717
db.replaceMany(NAME,
1818
arrayOf(X, Y, TYPE, DATE),
1919
tilesRect.asTilePosSequence().map { arrayOf<Any?>(

app/src/main/java/de/westnordost/streetcomplete/data/edithistory/EditHistoryController.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import de.westnordost.streetcomplete.data.osmnotes.edits.NoteEditsController
1212
import de.westnordost.streetcomplete.data.osmnotes.edits.NoteEditsSource
1313
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestController
1414
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestHidden
15-
import java.lang.System.currentTimeMillis
15+
import de.westnordost.streetcomplete.util.ktx.nowAsEpochMilliseconds
1616
import java.util.concurrent.CopyOnWriteArrayList
1717

1818
/** All edits done by the user in one place: Edits made on notes, on map data, hidings of quests */
@@ -88,7 +88,7 @@ class EditHistoryController(
8888
getAll().firstOrNull { it.isUndoable }
8989

9090
override fun getAll(): List<Edit> {
91-
val maxAge = currentTimeMillis() - MAX_UNDO_HISTORY_AGE
91+
val maxAge = nowAsEpochMilliseconds() - MAX_UNDO_HISTORY_AGE
9292

9393
val result = ArrayList<Edit>()
9494
result += elementEditsController.getAll().filter { it.action !is IsRevertAction }

app/src/main/java/de/westnordost/streetcomplete/data/elementfilter/filters/ElementFilter.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import de.westnordost.streetcomplete.data.osm.mapdata.Element
66
import de.westnordost.streetcomplete.osm.getLastCheckDateKeys
77
import de.westnordost.streetcomplete.osm.toCheckDate
88
import de.westnordost.streetcomplete.util.ktx.toLocalDate
9-
import java.time.Instant
10-
import java.time.LocalDate
9+
import kotlinx.datetime.Instant
10+
import kotlinx.datetime.LocalDate
1111

1212
sealed interface ElementFilter : Matcher<Element> {
1313
abstract override fun toString(): String
@@ -132,7 +132,7 @@ class TagNewerThan(key: String, dateFilter: DateFilter) : CompareTagAge(key, dat
132132
abstract class CompareTagAge(val key: String, val dateFilter: DateFilter) : ElementFilter {
133133
abstract fun compareTo(tagValue: LocalDate): Boolean
134134
override fun matches(obj: Element): Boolean {
135-
if (compareTo(Instant.ofEpochMilli(obj.timestampEdited).toLocalDate())) return true
135+
if (compareTo(Instant.fromEpochMilliseconds(obj.timestampEdited).toLocalDate())) return true
136136
return getLastCheckDateKeys(key)
137137
.mapNotNull { obj.tags[it]?.toCheckDate() }
138138
.any { compareTo(it) }
@@ -150,7 +150,7 @@ class ElementNewerThan(dateFilter: DateFilter) : CompareElementAge(dateFilter) {
150150

151151
abstract class CompareElementAge(val dateFilter: DateFilter) : ElementFilter {
152152
abstract fun compareTo(tagValue: LocalDate): Boolean
153-
override fun matches(obj: Element) = compareTo(Instant.ofEpochMilli(obj.timestampEdited).toLocalDate())
153+
override fun matches(obj: Element) = compareTo(Instant.fromEpochMilliseconds(obj.timestampEdited).toLocalDate())
154154
}
155155

156156
class CombineFilters(vararg val filters: ElementFilter) : ElementFilter {

0 commit comments

Comments
 (0)