diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt index 1edfe17..7e5fbec 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt @@ -18,7 +18,10 @@ package net.moonleay.lilJudd.util +import kotlinx.datetime.DayOfWeek import java.time.Duration +import java.time.ZoneId +import java.time.ZonedDateTime import java.util.concurrent.TimeUnit @@ -123,7 +126,20 @@ object TimeUtil { } } - fun getDelay(day: String): Int { - return DaysUntilMonday[day]!! + + // Returns the day of the month of the monday of this week + fun getMondayDayOfMonth(): Int { + return ZonedDateTime.now().with(DayOfWeek.MONDAY).dayOfMonth + } + + // Returns the day of the week as an int. Monday = 0; Sunday = 6 + fun getDayOfMonthInt(dow: DayOfWeek): Int { + return dow.value + } + + // Returns the day of the month of the monday of the current week + fun getWeekStamp(): ZonedDateTime { + return ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withDayOfMonth(getMondayDayOfMonth()).withHour(4) + .withMinute(0).withSecond(0) } }