Skip to content

fix(web): prevent comments showing 0y ago for 360-364 day old items (#3562) - #3573

Open
ghazy2001 wants to merge 2 commits into
CapSoftware:mainfrom
ghazy2001:fix/comment-time-ago-zero-year-3562
Open

ghazy2001 wants to merge 2 commits into
CapSoftware:mainfrom
ghazy2001:fix/comment-time-ago-zero-year-3562

Conversation

@ghazy2001

@ghazy2001 ghazy2001 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3562
Linear: CAP-952

Comments, share headers, and timeline branch cards that are 360–364 days old were displaying "0y ago".

Root Cause

formatTimeAgo in apps/web/app/s/[videoId]/_components/tabs/Activity/utils.ts transitioned from months to years once diffInMonths < 12 was false. At 360 days (12 * 30), diffInMonths reached 12, so it dropped into diffInYears = Math.floor(diffInDays / 365). For days 360 through 364, floor(days / 365) evaluated to 0, producing "0y ago".

Changes

  • Clamped diffInYears = Math.max(1, Math.floor(diffInDays / 365)) so that reaching the years branch guarantees at least "1y ago".
  • Added an optional now: Date = new Date() parameter to formatTimeAgo for clean, deterministic unit testing without timers/mocks.
  • Added comprehensive unit tests in apps/web/__tests__/unit/activity-time-ago.test.ts asserting 359d (11mo ago), 360–364d (1y ago), 365d (1y ago), and multi-year durations.

Test plan

  • Ran unit tests with Bun:
    • bun test apps/web/__tests__/unit/activity-time-ago.test.ts (3 pass, 13 assertions)
    • bun test apps/web/__tests__/unit/video-thumbnail-duration.test.ts (4 pass, 17 assertions)
    • bun test apps/mobile/src/utils/format.test.ts (4 pass, 19 assertions)
  • Verified 359 days renders as "11mo ago" and 360–364 days renders as "1y ago".

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Fixes formatTimeAgo so items aged 360–364 days show “1y ago” instead of “0y ago.”

  • Relative-time labels show at least one year in the year range.

Reviews (1) · Last reviewed commit: "fix(web): prevent comments showing 0y ag..." · Reviewed by Greptile

…apSoftware#3562)

When items reached 360 days (12 * 30), diffInMonths was 12, bypassing the months branch into diffInYears = floor(days / 365), which was 0 until day 365. This produced '0y ago' for items 360-364 days old.

Clamp diffInYears to at least 1 when reaching the years branch so near-year items render as '1y ago'. Also accept an optional now Date parameter to enable deterministic unit testing.

Closes CapSoftware#3562
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Oct 30, 2026 10:20pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status October 30, 2026 22:20 Inactive

This branch was previously deployed

1 inactive deployment
Preview – cap-status — de307dfb Deployed Oct 30, 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.

Comments show "0y ago" when they are 360–364 days old

1 participant