commonMain.dk.cachet.carp.common.application.InstantExtensions.kt Maven / Gradle / Ivy
Go to download
Helper classes and base types relied upon by all subsystems. This library does not contain any domain logic.
The newest version!
package dk.cachet.carp.common.application
import kotlinx.datetime.Instant
import kotlin.js.JsExport
private const val MICROS_PER_SECOND = 1_000_000
private const val NANOS_PER_MICRO = 1_000
/**
* Get the elapsed microseconds since the start of the UTC day 1970-01-01 at this [Instant]'s moment in time.
*/
@JsExport
@Suppress( "NON_EXPORTABLE_TYPE" )
fun Instant.toEpochMicroseconds(): Long = epochSeconds * MICROS_PER_SECOND + nanosecondsOfSecond / NANOS_PER_MICRO