aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
index b92cf5258..2aa542699 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeUtils.kt
@@ -85,13 +85,9 @@ object TimeUtils {
val Duration.inWholeTicks: Int
get() = (inWholeMilliseconds / 50).toInt()
+ fun getDuration(string: String) = getMillis(string.replace("m", "m ").replace(" ", " ").trim())
- @Deprecated("Do no longer use long for time", ReplaceWith("TimeUtils.getDuration(string)"))
- fun getMillis(string: String) = getDuration(string).inWholeMilliseconds
-
- fun getDuration(string: String) = getMillis_(string.replace("m", "m ").replace(" ", " ").trim())
-
- private fun getMillis_(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) {
+ private fun getMillis(string: String) = UtilsPatterns.timeAmountPattern.matchMatcher(string.lowercase().trim()) {
val years = group("y")?.toLong() ?: 0L
val days = group("d")?.toLong() ?: 0L
val hours = group("h")?.toLong() ?: 0L
@@ -131,7 +127,7 @@ object TimeUtils {
else -> {
throw RuntimeException("Invalid format: '$string'")
}
- }.toLong().toDuration(DurationUnit.MILLISECONDS)
+ }.milliseconds
}
fun SkyBlockTime.formatted(