Skip to content

[Bug] quietHours.ts uses UTC time instead of local time — quiet hours are wrong in every timezone #90

Description

@cybermax4200

Why this matters now: isNowInQuietHours() (line 11) computes now.getUTCHours() * 60 + now.getUTCMinutes() but the user-configured quiet hours (e.g., '22:00' to '07:00') are clearly local times. For a user in Nairobi (UTC+3) who sets quiet hours 22:00-07:00, the function evaluates against UTC, so notifications at 01:00 EAT (22:00 UTC) would be incorrectly suppressed, while notifications at 04:00 EAT (01:00 UTC) would incorrectly fire.

Problem / What: src/utils/quietHours.ts:11const nowMin = now.getUTCHours() * 60 + now.getUTCMinutes(). This should use now.getHours() and now.getMinutes() for local time.

Key Challenges:

  • Change getUTCHours() / getUTCMinutes() to getHours() / getMinutes().
  • Update the existing quietHours.test.ts (if any) to test with timezone offsets.
  • The dayKey function in streaks.ts uses local time (getFullYear/getMonth/getDate), which is correct — this inconsistency with quietHours.ts was likely an oversight.
  • Consider: should quiet hours be stored as UTC offsets or local time strings? The current approach (local time strings) is more user-friendly.

Acceptance Criteria:

  • isNowInQuietHours uses local time (getHours()/getMinutes()).
  • Tests verify correct behavior for UTC+0, UTC+3, UTC-5 timezones.
  • Quiet hours 22:00-07:00 correctly suppresses notifications at midnight local time in all timezones.
  • No other time-related functions use UTC inconsistently.

Relevant files/functions:

  • src/utils/quietHours.ts:11
  • src/__tests__/ (quietHours test, update or create)

Out of scope: Timezone-aware DST handling.

Labels: bug, intermediate, notifications

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions