Skip to content

Daily step reset happens at UTC midnight instead of the user's local midnight #10

Open

Description

@axe-fb

Problem

The daily auto-reset of steps/distance/calories fires at UTC midnight, not the user's local midnight. Any user not on UTC has their counters reset in the middle of the day.

Root cause

app.js:

function today() { return new Date().toISOString().slice(0, 10); }   // toISOString() is UTC

load() then does the daily reset based on this UTC date:

if (state.lastReset !== today()) {
  state.steps = 0; state.gpsDistM = 0; state.gpsSegments = 0;
  state.lastReset = today();
  state.running = false;
  save();
}

Because toISOString() returns the UTC calendar date, the "new day" boundary is 00:00 UTC. For example, a US-Pacific user's steps reset around 16:00–17:00 their local time.

Expected

Counters reset at the user's local midnight.

Suggested fix

Compute the local date instead of the UTC date, e.g.:

function today() {
  var d = new Date();
  return d.getFullYear() + '-' +
         String(d.getMonth() + 1).padStart(2, '0') + '-' +
         String(d.getDate()).padStart(2, '0');
}

(or new Date().toLocaleDateString('en-CA'), which yields YYYY-MM-DD in local time). lastReset is stored/compared with the same function, so only today() needs changing.

Activity

  1. added
    triage-send-to-botThis bug has been triaged, and the bot should pick up and create a PR for this.
    on Jul 12, 2026
  2. added
    jules-in-progressJules is currently working on this issue
    and removed
    triage-send-to-botThis bug has been triaged, and the bot should pick up and create a PR for this.
    on Jul 12, 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

    jules-in-progressJules is currently working on this issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions