diff options
-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) } |