Skip to content

Commit cbcb457

Browse files
authored
Remove Kotlinx Datetime (#706)
* Remove Kotlinx Datetime Signed-off-by: Matt Ramotar <matt.ramotar@uber.com> * Remove Kotlinx Datetime from libs.versions.toml Signed-off-by: Matt Ramotar <matt.ramotar@uber.com> * Update version Signed-off-by: Matt Ramotar <matt.ramotar@uber.com> --------- Signed-off-by: Matt Ramotar <matt.ramotar@uber.com>
1 parent d7af217 commit cbcb457

File tree

13 files changed

+65
-15
lines changed

13 files changed

+65
-15
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G
88

99
# POM file
1010
GROUP=org.mobilenativefoundation.store
11-
VERSION_NAME=5.1.0-alpha06
11+
VERSION_NAME=5.1.0-alpha07
1212
POM_PACKAGING=pom
1313
POM_DESCRIPTION = Store5 is a Kotlin Multiplatform network-resilient repository layer
1414

gradle/libs.versions.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ testCore = "1.6.1"
2121
kmmBridge = "0.3.2"
2222
ktlint = "0.39.0"
2323
kover = "0.9.0-RC"
24-
store = "5.1.0-alpha06"
24+
store = "5.1.0-alpha07"
2525
truth = "1.1.3"
2626
turbine = "1.2.0"
2727
binary-compatibility-validator = "0.15.0-Beta.2"
@@ -48,7 +48,6 @@ kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-
4848
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
4949
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
5050
kotlinx-coroutines-rx2 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx2", version.ref = "kotlinxCoroutines" }
51-
kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version = "0.6.2" }
5251
molecule-gradle-plugin = { module = "app.cash.molecule:molecule-gradle-plugin", version.ref = "moleculeGradlePlugin" }
5352
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "moleculeGradlePlugin" }
5453
rxjava = { group = "io.reactivex.rxjava2", name = "rxjava", version = "2.2.21" }

store/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ kotlin {
1313
implementation(libs.kotlin.stdlib)
1414
implementation(libs.kotlinx.coroutines.core)
1515
implementation(libs.kotlinx.serialization.core)
16-
implementation(libs.kotlinx.datetime)
1716
api(libs.kotlinx.atomic.fu)
1817
implementation(libs.touchlab.kermit)
1918
implementation(projects.multicast)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package org.mobilenativefoundation.store.store5.impl.extensions
2+
3+
internal actual fun currentTimeMillis(): Long = System.currentTimeMillis()

store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/StoreWriteRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.mobilenativefoundation.store.store5
22

3-
import kotlinx.datetime.Clock
43
import org.mobilenativefoundation.store.store5.impl.OnStoreWriteCompletion
54
import org.mobilenativefoundation.store.store5.impl.RealStoreWriteRequest
5+
import org.mobilenativefoundation.store.store5.impl.extensions.currentTimeMillis
66

77
interface StoreWriteRequest<Key : Any, Output : Any, Response : Any> {
88
val key: Key
@@ -15,7 +15,7 @@ interface StoreWriteRequest<Key : Any, Output : Any, Response : Any> {
1515
key: Key,
1616
value: Output,
1717
onCompletions: List<OnStoreWriteCompletion>? = null,
18-
created: Long = Clock.System.now().toEpochMilliseconds(),
18+
created: Long = currentTimeMillis(),
1919
): StoreWriteRequest<Key, Output, Response> = RealStoreWriteRequest(key, value, created, onCompletions)
2020
}
2121
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.mobilenativefoundation.store.store5.impl.extensions
2+
3+
import kotlin.time.Duration.Companion.hours
4+
5+
internal expect fun currentTimeMillis(): Long
6+
7+
internal fun now() = currentTimeMillis()
8+
9+
internal fun inHours(n: Int) = currentTimeMillis() + n.hours.inWholeMilliseconds

store/src/commonMain/kotlin/org/mobilenativefoundation/store/store5/impl/extensions/clock.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.mobilenativefoundation.store.store5.impl.extensions
2+
3+
import kotlinx.cinterop.ExperimentalForeignApi
4+
import kotlinx.cinterop.alloc
5+
import kotlinx.cinterop.memScoped
6+
import kotlinx.cinterop.ptr
7+
import platform.posix.gettimeofday
8+
import platform.posix.timeval
9+
10+
@OptIn(ExperimentalForeignApi::class)
11+
internal actual fun currentTimeMillis(): Long =
12+
memScoped {
13+
val tv = alloc<timeval>()
14+
gettimeofday(tv.ptr, null)
15+
(tv.tv_sec.toLong() * 1000L) + (tv.tv_usec.toLong() / 1000L)
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.mobilenativefoundation.store.store5.impl.extensions
2+
3+
@Suppress("UnsafeCastFromDynamic")
4+
internal actual fun currentTimeMillis(): Long =
5+
kotlin.js.Date
6+
.now()
7+
.toLong()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package org.mobilenativefoundation.store.store5.impl.extensions
2+
3+
internal actual fun currentTimeMillis(): Long = System.currentTimeMillis()

0 commit comments

Comments
 (0)