diff options
author | Phoebe <77941535+catgirlseraid@users.noreply.github.com> | 2024-05-25 00:43:28 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 14:43:28 +0200 |
commit | 9d89e6ae92910da36607b3eeed7328fae58be0ae (patch) | |
tree | c128066146478d2617808bf4b67c1584f8b337f1 /src/main/java/at/hannibal2/skyhanni | |
parent | 10c51c80f5546ae67e45bf6367dcc7e2622f6cdd (diff) | |
download | skyhanni-9d89e6ae92910da36607b3eeed7328fae58be0ae.tar.gz skyhanni-9d89e6ae92910da36607b3eeed7328fae58be0ae.tar.bz2 skyhanni-9d89e6ae92910da36607b3eeed7328fae58be0ae.zip |
Add 24h time toggle (#1804)
Co-authored-by: SeRaid <77941535+SeRaid743@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java index 5163bc4cd..1309780a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/GUIConfig.java @@ -51,6 +51,12 @@ public class GUIConfig { public float globalScale = 1F; @Expose + @ConfigOption(name = "Time Format", desc = "Change Skyhanni to use 24h time instead of 12h time.") + @ConfigEditorBoolean + @FeatureToggle + public boolean timeFormat24h = false; + + @Expose @ConfigOption(name = "Discord Rich Presence", desc = "") @Accordion public DiscordRPCConfig discordRPC = new DiscordRPCConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt index d818facfe..66286a489 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SimpleTimeMark.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.SkyHanniMod import java.time.Instant import java.time.LocalDateTime import java.time.ZoneId @@ -36,9 +37,15 @@ value class SimpleTimeMark(private val millis: Long) : Comparable<SimpleTimeMark } fun formattedDate(pattern: String): String { + val newPattern = if (SkyHanniMod.feature.gui.timeFormat24h) { + pattern.replace("h", "H").replace("a", "") + } else { + pattern + } + val instant = Instant.ofEpochMilli(millis) val localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()) - val formatter = DateTimeFormatter.ofPattern(pattern) + val formatter = DateTimeFormatter.ofPattern(newPattern.trim()) return localDateTime.format(formatter) } |