diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2023-06-17 14:27:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-17 22:27:51 +1000 |
commit | a04daf73a1a1d125177ba1cd47a0d21c3a969e73 (patch) | |
tree | 0841135a264b5b3aab178e01dfdb9b7360289ad1 /src/main/kotlin | |
parent | 4547611cda30c3169babb46fa71442ffd8fa80a1 (diff) | |
download | NotEnoughUpdates-a04daf73a1a1d125177ba1cd47a0d21c3a969e73.tar.gz NotEnoughUpdates-a04daf73a1a1d125177ba1cd47a0d21c3a969e73.tar.bz2 NotEnoughUpdates-a04daf73a1a1d125177ba1cd47a0d21c3a969e73.zip |
Add special mayor to calendar overlay (#685)
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt index 8ceb1c51..ac4ca360 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/SkyBlockTime.kt @@ -82,9 +82,9 @@ data class SkyBlockTime( val minute = getUnit(skyBlockMinute) val second = getUnit(skyBlockSecond) return SkyBlockTime(year, month, day, hour, minute, second) - } + @JvmStatic fun now(): SkyBlockTime { return fromInstant(Instant.now()) } @@ -108,6 +108,28 @@ data class SkyBlockTime( return prefix + name } + fun monthNameToInt(month: String): Int? { + val superSeason = when { + month.endsWith("Spring") -> 2 + month.endsWith("Summer") -> 5 + month.endsWith("Autumn") -> 8 + month.endsWith("Winter") -> 11 + else -> return null + } + val subSeason = when { + month.startsWith("Early") -> -1 + month.startsWith("Late") -> 1 + else -> 0 + } + return superSeason + subSeason + } + + fun fromDayMonthYear(day: Int, month: String, year: Int): SkyBlockTime? { + return monthNameToInt(month)?.let { + SkyBlockTime(year = year, month = it, day = day) + } + } + fun daySuffix(n: Int): String { return if (n in 11..13) { "th" |