feat: split getDelay function into three different getDelay functions
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
0a16994e61
commit
8bca3838bc
1 changed files with 18 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue