You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Days left" on goals and projects can be one day off, depending on timezone and time of day #8
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:
assets/js/goals.js: daysLeft in renderGoals (goal cards: "3 days left", "2 days late", "Due today")
Home already gets it right: goalDueText() in assets/js/dashboard.js compares local calendar days. Use it as your model.
Suggested fix
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.
Use it in goals.js, projects.js and goalDueText() in dashboard.js, so all three agree.
Write "1 day" / "N days" correctly (singular for 1).
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
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
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.
Activity
docs: explain how to pick and claim an issue; record D-016
[-]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[/+]abhinna123 commentedon Nov 11, 2026
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!
abhishekgoswami0720 commentedon Nov 11, 2026
Assigned to you, @abhinna123. Welcome! 🎉
A few tips for this one:
npm testdoes 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.freezeTime()fromtests/helpers/clock.jsin your tests to fix "now" to an exact moment.If you get stuck, comment here.