aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-05-13 12:01:10 +0200
committerGitHub <noreply@github.com>2024-05-13 12:01:10 +0200
commit5250a311250417f128cb6822075e8be0649c1bbc (patch)
treecf5a677297fd1ab5ff6289e975b11a207c39af02 /src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
parent4fe2010286136dc4192234c404f19fc720503765 (diff)
downloadskyhanni-5250a311250417f128cb6822075e8be0649c1bbc.tar.gz
skyhanni-5250a311250417f128cb6822075e8be0649c1bbc.tar.bz2
skyhanni-5250a311250417f128cb6822075e8be0649c1bbc.zip
Improvement: Time until Full Tower Charges (#1760)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
index 5178798a9..d818facfe 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt
@@ -1,6 +1,9 @@
package at.hannibal2.skyhanni.utils
import java.time.Instant
+import java.time.LocalDateTime
+import java.time.ZoneId
+import java.time.format.DateTimeFormatter
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
@@ -32,6 +35,13 @@ value class SimpleTimeMark(private val millis: Long) : Comparable<SimpleTimeMark
return Instant.ofEpochMilli(millis).toString()
}
+ fun formattedDate(pattern: String): String {
+ val instant = Instant.ofEpochMilli(millis)
+ val localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault())
+ val formatter = DateTimeFormatter.ofPattern(pattern)
+ return localDateTime.format(formatter)
+ }
+
fun toMillis() = millis
fun toSkyBlockTime() = SkyBlockTime.fromInstant(Instant.ofEpochMilli(millis))