diff options
author | nea <nea@nea.moe> | 2023-05-26 23:23:03 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-26 23:23:03 +0200 |
commit | 59ea00dabceeddf01fec7bf87ec548d7beedd7cc (patch) | |
tree | 9711c61022f2bac793c423de97901d2370b7c316 /src/main/kotlin/moe/nea/firmament/util/TimeMark.kt | |
parent | 484a4b1a61493eb1401ac9c8ac063db3f847cf98 (diff) | |
download | firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.tar.gz firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.tar.bz2 firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.zip |
Fix bug in WFixedPanel and use WScrollPanel + WBox for config
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/util/TimeMark.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/util/TimeMark.kt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt b/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt index e9826f1..3331a76 100644 --- a/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt +++ b/src/main/kotlin/moe/nea/firmament/util/TimeMark.kt @@ -23,11 +23,18 @@ import kotlin.time.ExperimentalTime import kotlin.time.TimeSource @OptIn(ExperimentalTime::class) -class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) { +class TimeMark private constructor(private val timeMark: TimeSource.Monotonic.ValueTimeMark?) : Comparable<TimeMark> { fun passedTime() = timeMark?.elapsedNow() ?: Duration.INFINITE companion object { fun now() = TimeMark(TimeSource.Monotonic.markNow()) fun farPast() = TimeMark(null) } + + override fun compareTo(other: TimeMark): Int { + if (this.timeMark == other.timeMark) return 0 + if (this.timeMark == null) return -1 + if (other.timeMark == null) return -1 + return this.timeMark.compareTo(other.timeMark) + } } |