aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt
blob: be5f593224236729d250a943d87624799ed783d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package at.hannibal2.skyhanni.utils

import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

data class TimeMark(val long: Long) {

    fun hasNeverHappened() = long == 0L
    fun passedTime() = if (long == 0L) Duration.Companion.INFINITE else (System.currentTimeMillis() - long).milliseconds

    companion object {

        fun never() = TimeMark(0)
        fun now() = TimeMark(System.currentTimeMillis())
    }
}