Skip to content

fix(airdatebadge): anchor day diff to UTC midnight instead of raw ms delta #3273

Open
fallenbagel wants to merge 1 commit into
developfrom
fix/airdatebadge-utc-day-boundary
Open

fix(airdatebadge): anchor day diff to UTC midnight instead of raw ms delta #3273
fallenbagel wants to merge 1 commit into
developfrom
fix/airdatebadge-utc-day-boundary

Conversation

@fallenbagel

@fallenbagel fallenbagel commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description

AirDateBadge computed the relative day count by rounding a raw millisecond delta between the exact current instant and a UTC-midnight air date, so the day boundary landed at noon UTC instead of an actual calendar day change. On an episode's air date the badge flipped from "Aired today" to "Aired yesterday" starting at noon UTC, and the day before an air date it showed "Airing today" from noon UTC onward for an episode that doesn't air until the next day.

Both dates are now truncated to UTC midnight before diffing, so the day count is always a whole number with no rounding involved. TMDB's air_date has no time or timezone attached, it's just the origin country's local date, so UTC isn't more "correct" here, it's just deterministic just like the absolute date badge next to it, which is already rendered in UTC. As a side effect, the Aired/Airing split changes slightly as the badge now reads "Airing" for the entire UTC day an episode airs and switches to "Aired" starting the following UTC day, instead of flipping almost immediately after midnight like before. Also renamed the WEEK constant to make it less confusing.

How Has This Been Tested?

  • Simulated the code logic with an injectable clock, and compared side by side with the old logic

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Summary by CodeRabbit

  • Bug Fixes
    • Improved air date labels by standardizing relative-date calculations using UTC midnight timestamps.
    • Fixed incorrect “upcoming” vs “already aired” results near day boundaries and across time zones.
    • Refined when relative-date text appears by using a consistent UTC-based 8-day window.
    • Enhanced date-difference accuracy for clearer scheduling information.

@fallenbagel
fallenbagel requested a review from a team as a code owner July 20, 2026 21:56
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

AirDateBadge compares air dates and the current date at UTC midnight, determines relative-display eligibility within an eight-day window, and passes an unrounded day difference to relative-time formatting.

Changes

AirDateBadge relative-date calculation

Layer / File(s) Summary
UTC date comparison
src/components/AirDateBadge/index.tsx
Normalizes both dates to UTC midnight, derives elapsed milliseconds and aired status, limits relative labels to eight days, and removes day-count rounding.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit with dates in a row,
Now UTC tells when they should show.
No rounding jumps at noon’s bright light,
Eight days keep the labels right.
Hop, hop—clear air dates tonight!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change matches issue #3268 by basing relative labels on UTC calendar days and avoiding noon-UTC rounding shifts.
Out of Scope Changes check ✅ Passed The PR appears limited to the AirDateBadge fix and does not introduce unrelated scope.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the core AirDateBadge change to UTC-midnight day-difference calculation and is concise.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fallenbagel
fallenbagel force-pushed the fix/airdatebadge-utc-day-boundary branch from b6e3aae to aa63888 Compare July 20, 2026 21:58
…delta

Math.round() on a raw ms delta flipped the relative label at noon UTC instead of the actual day
boundary; both dates now truncate to UTC midnight before diffing.

fix #3268
@fallenbagel
fallenbagel force-pushed the fix/airdatebadge-utc-day-boundary branch from aa63888 to b82c690 Compare July 20, 2026 21:59
coderabbitai[bot]

This comment was marked as off-topic.

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.

diffInDays Rounding Causes Undesirable AirDateBadge Relative Values

1 participant