Skip to content

[BUG] Streak uses the UTC date instead of the user's local date #116

Open

Description

@patrik1531

Description

updateStreak in src/utils/stats.ts computes "today" and "yesterday" from new Date().toISOString(), which gives the UTC calendar date. The rest of the planner (week ids, days) uses the local date (src/types/weekUtils.ts).

For users outside UTC, activity near midnight is recorded on the wrong day:

  • In UTC+2 (e.g. Central Europe in summer), completing a block at 00:30 local time on Tuesday stores lastActiveDate as Monday.
  • Two activities at 23:30 Monday and 00:30 Tuesday local time can land on the same UTC date, so the streak is not incremented even though the user was active on two consecutive local days.
  • West of UTC the opposite happens in the evening.

Steps to reproduce

  1. Set the device timezone to UTC+2.
  2. Complete a block at 00:30 local time.
  3. lastActiveDate (AsyncStorage @levelup/last_active) holds the previous day's date.

Expected behavior

Streak days follow the user's local calendar, consistent with the planner weeks.

Suggested fix

Build the date string from local fields (getFullYear(), getMonth(), getDate()), as getWeekId already does, and compute "yesterday" the same way. Existing users' stored lastActiveDate values stay valid (same YYYY-MM-DD format).

Found while writing tests; drafted with the help of Claude Code.

Activity

  1. added
    bugSomething isn't working
    gamificationRelated to achievements, streaks, and progression
    on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggamificationRelated to achievements, streaks, and progressiongood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions