aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/util/TimeMark.kt
blob: 51966061e3976e5e19464fb41119bdb0f09a10c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package moe.nea.notenoughupdates.util

import kotlin.time.Duration
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource

@OptIn(ExperimentalTime::class)
class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) {
    fun passedTime() = timeMark?.elapsedNow() ?: Duration.INFINITE

    companion object {
        fun now() = TimeMark(TimeSource.Monotonic.markNow())
        fun farPast() = TimeMark(null)
    }
}