Skip to content

"Days left" on goals and projects can be one day off, depending on timezone and time of day #8

Closed

Description

@abhishekgoswami0720

What's wrong

Goal and project cards work out "days left" by comparing new Date(deadline) with the current time. new Date('2026-11-07') means midnight UTC, not midnight where the user is, so the count is wrong for part of every day:

Where Due date Time now Shows Should show
India (UTC+5:30) today 04:00 1 days left Due today
US West (UTC−8) today 20:00 1 days late Due today
US West (UTC−8) tomorrow 20:00 Due today 1 day left

There is a second, smaller bug in the same place: one day says "1 days" instead of "1 day".

(Checked against the current code on 8 Nov 2026 with TZ=Asia/Kolkata and TZ=America/Los_Angeles.)

Where

The wrong calculation is in two places:

Home already gets it right: goalDueText() in assets/js/dashboard.js compares local calendar days. Use it as your model.

Suggested fix

  1. Add one helper to assets/js/utils.js, e.g. daysUntil(dateStr), that compares local calendar days: new Date(dateStr + 'T00:00:00') minus new Date(getTodayISO() + 'T00:00:00'), divided by one day and rounded (the T00:00:00 makes both local midnight). Return null for a missing or invalid date.
  2. Use it in goals.js, projects.js and goalDueText() in dashboard.js, so all three agree.
  3. Write "1 day" / "N days" correctly (singular for 1).
  4. Add tests to tests/utils.test.js using freezeTime() from tests/helpers/clock.js: due today early in the morning and late in the evening, due tomorrow, one day late, missing or invalid date. npm test repeats them in 4 timezones automatically.

Done when

  • Goals, projects and Home use the same helper
  • New tests pass with npm test (all 4 timezones)
  • A goal due today shows Due today at any hour, in any timezone
  • One day shows as "1 day", not "1 days"

See docs/DECISIONS.md D-007 for why the app uses local calendar days.

Activity

  1. changed the title [-]Goal and project deadlines show the wrong day depending on timezone[/-] [+]"Days left" on goals and projects can be one day off, depending on timezone and time of day[/+] on Nov 8, 2026
  2. abhinna123 commented on Nov 11, 2026

    @abhinna123
    Contributor

    I’d like to work on issue #8 (Days left on goals and projects can be one day off, depending on timezone and time of day).

    I find this bug interesting and would like to contribute by fixing it. Please assign this issue to me.

    Thank you!

  3. abhishekgoswami0720 commented on Nov 11, 2026

    @abhishekgoswami0720
    CollaboratorAuthor

    Assigned to you, @abhinna123. Welcome! 🎉

    A few tips for this one:

    • Start by reproducing it. The "Done when" list in the issue says what the fix needs to handle.
    • Our tests run in 4 timezones (npm test does this for you), so a fix that only works in IST will fail CI. That's on purpose, it's what makes this bug interesting.
    • Use freezeTime() from tests/helpers/clock.js in your tests to fix "now" to an exact moment.
    • Open a draft PR early if you want feedback on your approach before you finish.

    If you get stuck, comment here.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdates & timezonesBugs or work involving local dates, timezones or DSTdifficulty: easyA few hours; good for a first contributiongood first issueGood for newcomers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions