Skip to content

Fix talk reminders firing 2h late by using device timezone#1

Closed
GerardPaligot wants to merge 1 commit into
mainfrom
fix/notification-timezone
Closed

Fix talk reminders firing 2h late by using device timezone#1
GerardPaligot wants to merge 1 commit into
mainfrom
fix/notification-timezone

Conversation

@GerardPaligot

Copy link
Copy Markdown

Problem

Local notifications for favorited talks fire 2 hours late on Android for an event in Lille (Europe/Paris).

The backend returns schedule times as event-local wall-clock LocalDateTime strings with no offset, e.g.:

"start_time": "2026-06-11T08:30"

AlarmScheduler.android.kt re-attached TimeZone.UTC to that value, turning "08:30 Lille" into "08:30 UTC" = "10:30 Lille". The error equals Europe/Paris's summer offset (CEST = UTC+2).

Root cause

The backend is correct — it stores UTC instants and renders them into the event timezone for the V4 payload. The bug was solely on the consumer:

// before — AlarmScheduler.android.kt
talkItem.startTime.toLocalDateTime().toInstant(TimeZone.UTC)

Fix

Interpret the start time in TimeZone.currentSystemDefault() so the alarm fires at the time displayed in the app. This matches the existing convention in Sessions.kt (tabSelected() / closestTimeSlotKey()), which already compares schedule times against the device's local "now".

The conversion is extracted into a pure reminderTriggerAtMillis() helper in commonMain so it can be unit-tested deterministically with an explicit timezone.

Tests

  • New ReminderTimeTest: "2026-06-11T08:30" in Europe/Paris + 10-min reminder → 06:20 UTC, with a regression guard asserting it is not 08:20 UTC (the old behavior).
  • :shared:core:desktopTest, :shared:core:compileAndroidMain, :shared:core:ktlintCheck, :shared:core:detekt all pass.

Known limitation

Uses the device timezone, which is correct for an attendee whose phone is in the event's zone. Making cross-timezone reminder-setting watertight would require exposing the event timezone (already in EventsTable.timezone) through the client DTOs/DB — a larger follow-up.

🤖 Generated with Claude Code

Schedule start times come from the backend as event-local wall-clock
LocalDateTime strings without an offset (e.g. "2026-06-11T08:30" for a
session in Lille). The Android alarm scheduler re-interpreted them as
UTC, so for a Europe/Paris event the reminder fired CEST's +2h offset
late.

Interpret the start time in TimeZone.currentSystemDefault() instead, so
the alarm fires at the time displayed in the app. This matches the
existing convention in Sessions.kt (tabSelected/closestTimeSlotKey),
which already compares schedule times against the device's local now.

Extract the conversion into a pure reminderTriggerAtMillis() helper in
commonMain so it can be unit-tested deterministically with an explicit
timezone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@GerardPaligot GerardPaligot deleted the fix/notification-timezone branch June 11, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant