diff options
author | nea <nea@nea.moe> | 2023-07-18 02:52:25 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-07-18 02:53:37 +0200 |
commit | 25fb78ace82779fa6e5b45fc20fa428570c63a59 (patch) | |
tree | 957b67b0d18e8b33bb4c1f6222e5ffb41ccf0e91 /src/main/kotlin/com/dulkirfabric/util/TimeMark.kt | |
parent | d68c8bb34fe41d47777c4771364d2b94b4fdbdf1 (diff) | |
download | DulkirMod-Fabric-25fb78ace82779fa6e5b45fc20fa428570c63a59.tar.gz DulkirMod-Fabric-25fb78ace82779fa6e5b45fc20fa428570c63a59.tar.bz2 DulkirMod-Fabric-25fb78ace82779fa6e5b45fc20fa428570c63a59.zip |
DUDUDUDUDUDUDUDUDUDUDUDUDUDU
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/util/TimeMark.kt')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/util/TimeMark.kt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/util/TimeMark.kt b/src/main/kotlin/com/dulkirfabric/util/TimeMark.kt new file mode 100644 index 0000000..c6b2427 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/util/TimeMark.kt @@ -0,0 +1,23 @@ +package com.dulkirfabric.util + +import java.time.Duration + +data class TimeMark(val timestamp: Long) { + companion object { + fun now(): TimeMark { + return TimeMark(System.currentTimeMillis()) + } + + fun ago(duration: Duration): TimeMark { + return TimeMark(System.currentTimeMillis() - duration.toMillis()) + } + + fun farPast(): TimeMark { + return TimeMark(0L) + } + } + + fun timePassed(): Duration { + return Duration.ofMillis(System.currentTimeMillis() - timestamp) + } +}
\ No newline at end of file |