@@ -3,7 +3,6 @@ package io.github.kevincianfarini.cardiologist.impl
33import kotlinx.datetime.LocalDateTime
44import kotlinx.datetime.Month
55import kotlinx.datetime.number
6- import kotlin.math.min
76
87internal fun LocalDateTime.nextMatch (
98 atSeconds : IntRange = 0..59,
@@ -62,10 +61,6 @@ private fun LocalDateTime.nextMonth(
6261 }
6362}
6463
65- private operator fun Month.inc (): Month {
66- return Month .entries[(ordinal + 1 ) % 12 ]
67- }
68-
6964private fun LocalDateTime.nextDay (
7065 onDaysOfMonth : IntRange ,
7166 inMonths : ClosedRange <Month >,
@@ -106,7 +101,12 @@ private fun LocalDateTime.nextHour(
106101 incrementedHour < hour -> nextDay(onDaysOfMonth, inMonths, increment = true ).copy(hour = incrementedHour)
107102 incrementedHour in atHours -> copy(hour = incrementedHour)
108103 incrementedHour < atHours.first -> copy(hour = atHours.first, minute = 0 , second = 0 , nanosecond = 0 )
109- incrementedHour > atHours.last -> nextDay(onDaysOfMonth, inMonths, increment = true ).copy(hour = atHours.first)
104+ incrementedHour > atHours.last -> nextDay(onDaysOfMonth, inMonths, increment = true ).copy(
105+ hour = atHours.first,
106+ minute = 0 ,
107+ second = 0 ,
108+ nanosecond = 0 ,
109+ )
110110 else -> error(" This should be impossible." )
111111 }
112112}
@@ -127,7 +127,9 @@ private fun LocalDateTime.nextMinute(
127127 incrementedMinute in atMinutes -> copy(minute = incrementedMinute)
128128 incrementedMinute < atMinutes.first -> copy(minute = atMinutes.first, second = 0 , nanosecond = 0 )
129129 incrementedMinute > atMinutes.last -> nextHour(atHours, onDaysOfMonth, inMonths, increment = true ).copy(
130- minute = atMinutes.first
130+ minute = atMinutes.first,
131+ second = 0 ,
132+ nanosecond = 0 ,
131133 )
132134 else -> error(" This should be impossible." )
133135 }
@@ -189,3 +191,7 @@ internal fun LocalDateTime.copy(
189191 second : Int = this.second,
190192 nanosecond : Int = this.nanosecond,
191193) = LocalDateTime (year, monthNumber, dayOfMonth, hour, minute, second, nanosecond)
194+
195+ private operator fun Month.inc (): Month {
196+ return Month .entries[(ordinal + 1 ) % 12 ]
197+ }
0 commit comments