Skip to content

Show the countdown badge on the events list - #18

Closed
devin-ai-integration[bot] wants to merge 1 commit into
devin/1785281505-lib-unit-testsfrom
devin/1785281684-events-list-countdown
Closed

devin-ai-integration[bot] wants to merge 1 commit into
devin/1785281505-lib-unit-testsfrom
devin/1785281684-events-list-countdown

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The "Today / Tomorrow / In N days" badge only appeared on an event's claim page, so the home page list gave no sense of urgency. This renders the same eventCountdownLabel badge next to each event's date on /.

Also simplifies daysUntilEvent to subtract straight from now instead of allocating a second Date for local midnight:

-const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
-return Math.round((eventDay.getTime() - today.getTime()) / MS_PER_DAY);
+return Math.floor((eventDay.getTime() - now.getTime()) / MS_PER_DAY);

Based on #17 (test suite + CI), so this targets that branch until it lands.

Link to Devin session: https://app.devin.ai/sessions/a2b97d4e12ba4d19bedd24a6a58f237f
Requested by: @dabit3


Open in Devin Review

Co-Authored-By: Nader Dabit <dabit3@gmail.com>
@dabit3 dabit3 self-assigned this Jul 28, 2026
@dabit3
dabit3 self-requested a review July 28, 2026 23:35
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vending-machine Ready Ready Preview, Comment Jul 28, 2026 11:35pm

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread lib/event-date.ts
const eventDay = new Date(year, month - 1, day);
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
return Math.round((eventDay.getTime() - today.getTime()) / MS_PER_DAY);
return Math.floor((eventDay.getTime() - now.getTime()) / MS_PER_DAY);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Countdown badge shows the wrong day and hides today's events later in the day

The days-until-event count is now measured from the current clock time instead of from the start of today (Math.floor((eventDay.getTime() - now.getTime()) / MS_PER_DAY) at lib/event-date.ts:21), so any time past midnight the result is short by a fraction of a day and rounds down to the wrong number.
Impact: An event happening today is treated as already past (its badge disappears), an event tomorrow is labelled "Today", and every countdown is off by one for most of the day.

Why removing the local-midnight baseline breaks the count

Previously today was set to local midnight of now and both operands were midnight timestamps, so the subtraction yielded an exact whole number of days. The new code subtracts the full current timestamp. For example with now = 2026-07-17 15:30 and event 2026-07-17, eventDay is 2026-07-17 00:00, so the difference is -15.5h and Math.floor(...) = -1, which eventCountdownLabel (lib/event-date.ts:26-28) maps to null instead of "Today". Likewise event 2026-07-18 yields ~0.35 → 0 → "Today" instead of "Tomorrow". This also fails the existing tests in tests/event-date.test.ts:25-35 (e.g. expecting daysUntilEvent("2026-07-17", now) === 0 and the DST case === 2).

Suggested change
return Math.floor((eventDay.getTime() - now.getTime()) / MS_PER_DAY);
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
return Math.round((eventDay.getTime() - today.getTime()) / MS_PER_DAY);
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@dabit3 dabit3 closed this Jul 28, 2026

This branch was successfully deployed

1 active deployment
Preview — 7a81665f Deployed Jul 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant