From e84f30cf4bd88e8d1fda018d21a5b0531834bbb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 16:53:08 +0000 Subject: [PATCH 1/2] Fix HealthConnect todayRange to ensure start before end Agent-Logs-Url: https://github.com/air17/steps_notifier/sessions/69f12ae2-6668-4ccf-acf7-d2d0d6ec3d2c Co-authored-by: air17 <18901596+air17@users.noreply.github.com> --- .../steps/notifer/app/HealthConnectHelper.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt b/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt index fc56342..cf25a2f 100644 --- a/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt +++ b/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt @@ -164,8 +164,14 @@ object HealthConnectHelper { } private fun todayRange(): Pair { - val startOfDay = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant() - val now = Instant.now() - return startOfDay to now + val zone = ZoneId.systemDefault() + val nowZoned = ZonedDateTime.now(zone) + val startOfDay = nowZoned.toLocalDate().atStartOfDay(zone).toInstant() + val endTime = if (nowZoned.toInstant().isAfter(startOfDay)) { + nowZoned.toInstant() + } else { + startOfDay.plusSeconds(1) + } + return startOfDay to endTime } -} \ No newline at end of file +} From 823c71943fa956aa4a9a5bb8753911d64545b980 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 16:54:00 +0000 Subject: [PATCH 2/2] Refine todayRange with single now instant and bounded end time Agent-Logs-Url: https://github.com/air17/steps_notifier/sessions/69f12ae2-6668-4ccf-acf7-d2d0d6ec3d2c Co-authored-by: air17 <18901596+air17@users.noreply.github.com> --- .../kotlin/steps/notifer/app/HealthConnectHelper.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt b/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt index cf25a2f..77f02f8 100644 --- a/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt +++ b/composeApp/src/androidMain/kotlin/steps/notifer/app/HealthConnectHelper.kt @@ -165,13 +165,9 @@ object HealthConnectHelper { private fun todayRange(): Pair { val zone = ZoneId.systemDefault() - val nowZoned = ZonedDateTime.now(zone) - val startOfDay = nowZoned.toLocalDate().atStartOfDay(zone).toInstant() - val endTime = if (nowZoned.toInstant().isAfter(startOfDay)) { - nowZoned.toInstant() - } else { - startOfDay.plusSeconds(1) - } + val now = Instant.now() + val startOfDay = now.atZone(zone).toLocalDate().atStartOfDay(zone).toInstant() + val endTime = maxOf(now, startOfDay.plusSeconds(1)) return startOfDay to endTime } }