feat: split getDelay function into three different getDelay functions

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-28 22:39:15 +02:00
parent 0a16994e61
commit 8bca3838bc

View file

@ -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)
}
}