Skip to content

Show Full Date for "Last Checked" in the Profile Watchlist #36

Description

@Vedant1703

In the Profile page → Watched Repositories section, each watched repo shows a "Last checked" timestamp. Currently, it is rendered using .toLocaleTimeString() which only shows the time — for example: "3:45:02 PM".

If a repo was last checked yesterday, 3 days ago, or last week, the user sees no date context at all — just a meaningless time like "11:30:00 AM". This is confusing and unhelpful.


📍 File to Change

frontend/app/(auth)/profile/page.tsx — inside the Watchlist sub-component (around line 271)


🔍 Current Code (line ~271)

<span className="flex items-center gap-1">
  <Bell className="w-3 h-3"/>
  Last checked: {repo.last_checked_at 
    ? new Date(repo.last_checked_at).toLocaleTimeString()  // ← PROBLEM: no date!
    : 'Never'}
</span>

✅ What To Do

Option A (Recommended) — Relative time (e.g., "2 hours ago", "3 days ago"):

Add a formatTimeAgo helper (already exists in notifications/page.tsx — you can copy it into frontend/lib/utils.ts to share it):

// In frontend/lib/utils.ts
export function formatTimeAgo(date: Date): string {
  const seconds = Math.floor((new Date().getTime() - date.getTime()) / 1000);
  if (seconds < 60) return `${seconds}s ago`;
  const minutes = Math.floor(seconds / 60);
  if (minutes < 60) return `${minutes}m ago`;
  const hours = Math.floor(minutes / 60);
  if (hours < 24) return `${hours}h ago`;
  const days = Math.floor(hours / 24);
  return `${days}d ago`;
}

Then use it:

Last checked: {repo.last_checked_at 
  ? formatTimeAgo(new Date(repo.last_checked_at))
  : 'Never'}

Option B — Full locale string:

Last checked: {repo.last_checked_at 
  ? new Date(repo.last_checked_at).toLocaleString()  // Shows date + time
  : 'Never'}

Either option is acceptable — relative time (Option A) is preferred.


🏁 Acceptance Criteria

  • "Last checked" in the Watchlist section of the Profile page shows date context (relative or full date+time)
  • If last_checked_at is null, it still shows "Never"
  • The change is inside the Watchlist component in profile/page.tsx
  • (Bonus) The formatTimeAgo helper is extracted to frontend/lib/utils.ts and imported in both profile/page.tsx and notifications/page.tsx

💡 Technical Hints

  • The bug is at line ~271 in frontend/app/(auth)/profile/page.tsx — find .toLocaleTimeString() and replace it
  • The formatTimeAgo function already exists in frontend/app/(auth)/notifications/page.tsx — no need to write it from scratch, just move it to a shared utility

🚀 Getting Started

  1. Fork the repository
  2. Create a branch: git checkout -b fix/issue-6-watchlist-date-format
  3. Edit frontend/app/(auth)/profile/page.tsx
  4. Optionally, extract formatTimeAgo to frontend/lib/utils.ts
  5. Run locally: cd frontend && npm run dev → navigate to /profile
  6. Open a Pull Request!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions