jvmMain.io.islandtime.clock.internal.SystemClockImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-metadata Show documentation
Show all versions of core-metadata Show documentation
A multiplatform library for working with dates and times
The newest version!
package io.islandtime.clock.internal
import io.islandtime.Instant
import io.islandtime.PlatformInstant
import io.islandtime.TimeZone
import io.islandtime.clock.SystemClock
import io.islandtime.jvm.toIslandInstant
import io.islandtime.measures.LongMilliseconds
import io.islandtime.measures.milliseconds
import java.time.Clock as JavaClock
private val javaClock = JavaClock.systemUTC()
internal actual fun createSystemClock(zone: TimeZone): SystemClock {
return object : SystemClock() {
override val zone: TimeZone = zone
override fun readMilliseconds(): LongMilliseconds = System.currentTimeMillis().milliseconds
override fun readInstant(): Instant = readPlatformInstant().toIslandInstant()
override fun readPlatformInstant(): PlatformInstant = javaClock.instant()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy