Repository: kevincianfarini/cardiologist (kotlin)

Issue:
2024-01-18T23:59:48 matches to wrong next local date
Failing test case: 

```kt
    @Test fun matches_jan_18_2024_to_jan_19_2024() = assertEquals(
        expected = LocalDateTime(year = 2024, monthNumber = 1, dayOfMonth = 19, hour = 0, minute = 0),
        actual = LocalDateTime(year = 2024, monthNumber = 1, dayOfMonth = 18, hour = 23, minute = 59, second = 48)
            .nextMatch(atSeconds = 0..0, atMinutes = 0..0, atHours = 0..0)
    )
```

Pull request:
Closes #26

Patch:
diff --git a/gradle.properties b/gradle.properties
index 9790207..d7f90ca 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,7 +2,7 @@ kotlin.code.style=official
 
 GROUP=io.github.kevincianfarini.cardiologist
 POM_ARTIFACT_ID=cardiologist
-VERSION_NAME=0.2.0
+VERSION_NAME=0.3.0
 
 POM_NAME=Cardiologist
 POM_DESCRIPTION=Build job schedules with kotlinx-datetime and kotlinx-coroutines.
diff --git a/src/commonMain/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTime.kt b/src/commonMain/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTime.kt
index ea4505c..14299c5 100644
--- a/src/commonMain/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTime.kt
+++ b/src/commonMain/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTime.kt
@@ -3,7 +3,6 @@ package io.github.kevincianfarini.cardiologist.impl
 import kotlinx.datetime.LocalDateTime
 import kotlinx.datetime.Month
 import kotlinx.datetime.number
-import kotlin.math.min
 
 internal fun LocalDateTime.nextMatch(
     atSeconds: IntRange = 0..59,
@@ -62,10 +61,6 @@ private fun LocalDateTime.nextMonth(
     }
 }
 
-private operator fun Month.inc(): Month {
-    return Month.entries[(ordinal + 1) % 12]
-}
-
 private fun LocalDateTime.nextDay(
     onDaysOfMonth: IntRange,
     inMonths: ClosedRange<Month>,
@@ -106,7 +101,12 @@ private fun LocalDateTime.nextHour(
         incrementedHour < hour -> nextDay(onDaysOfMonth, inMonths, increment = true).copy(hour = incrementedHour)
         incrementedHour in atHours -> copy(hour = incrementedHour)
         incrementedHour < atHours.first -> copy(hour = atHours.first, minute = 0, second = 0, nanosecond = 0)
-        incrementedHour > atHours.last -> nextDay(onDaysOfMonth, inMonths, increment = true).copy(hour = atHours.first)
+        incrementedHour > atHours.last -> nextDay(onDaysOfMonth, inMonths, increment = true).copy(
+            hour = atHours.first,
+            minute = 0,
+            second = 0,
+            nanosecond = 0,
+        )
         else -> error("This should be impossible.")
     }
 }
@@ -127,7 +127,9 @@ private fun LocalDateTime.nextMinute(
         incrementedMinute in atMinutes -> copy(minute = incrementedMinute)
         incrementedMinute < atMinutes.first -> copy(minute = atMinutes.first, second = 0, nanosecond = 0)
         incrementedMinute > atMinutes.last -> nextHour(atHours, onDaysOfMonth, inMonths, increment = true).copy(
-            minute = atMinutes.first
+            minute = atMinutes.first,
+            second = 0,
+            nanosecond = 0,
         )
         else -> error("This should be impossible.")
     }
@@ -189,3 +191,7 @@ internal fun LocalDateTime.copy(
     second: Int = this.second,
     nanosecond: Int = this.nanosecond,
 ) = LocalDateTime(year, monthNumber, dayOfMonth, hour, minute, second, nanosecond)
+
+private operator fun Month.inc(): Month {
+    return Month.entries[(ordinal + 1) % 12]
+}


Test patch:
diff --git a/src/commonTest/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTimeTest.kt b/src/commonTest/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTimeTest.kt
index efb4502..65105f1 100644
--- a/src/commonTest/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTimeTest.kt
+++ b/src/commonTest/kotlin/io/github/kevincianfarini/cardiologist/impl/LocalDateTimeTest.kt
@@ -169,6 +169,12 @@ class LocalDateTimeTest {
         )
     )
 
+    @Test fun matches_jan_18_2024_to_jan_19_2024() = assertEquals(
+        expected = LocalDateTime(year = 2024, monthNumber = 1, dayOfMonth = 19, hour = 0, minute = 0),
+        actual = LocalDateTime(year = 2024, monthNumber = 1, dayOfMonth = 18, hour = 23, minute = 59, second = 48)
+            .nextMatch(atSeconds = 0..0, atMinutes = 0..0, atHours = 0..0)
+    )
+
     @Test fun one_month_gap_for_two_years() {
         LocalDateTime(year = 2023, monthNumber = 1, dayOfMonth = 1, hour = 0, minute = 0).assertGap(
             assertPeriod = DateTimePeriod(months = 1),