Skip to content

Extend formatDueAt with weeks/months granularity for future and past due dates #760

Description

@gaidheal1

Summary

formatDueAt (frontend/src/utils/formatUtils.ts:78-104) renders relative due dates for TasksPanel (Due {meta.dueAt} — see TasksPanel.tsx:103), but its granularity is coarse on both sides of "now": each direction only gets one bucket before falling back to something coarser, instead of scaling smoothly the way "last worked on" (useTasksPanel.tsx:88-96) does with days → weeks.

Requested: for both future and past due dates, scale granularity — days, then weeks (optionally with a leftover-days remainder), then months once it's far enough out — instead of dropping to an absolute date (future) or a bare "N weeks ago" with no cap (past).

Current behavior

diffDays Output
... ...
-6 to -2 N days ago
< -6 N weeks ago (uncapped — keeps growing indefinitely, e.g. 26 weeks ago)
-1 Yesterday
0 Today
1 Tomorrow
2–6 in N days
> 6 absolute date, e.g. Fri 24th Jul

Requested behavior

Range Output
beyond ~2 months ago N months ago
~1–8 weeks ago N weeks[, M days] ago — e.g. 2 weeks, 3 days ago, 1 week ago (omit days remainder when 0)
2–6 days ago N days ago (unchanged)
-1 Yesterday
0 Today
1 Tomorrow
2–6 days in N days (unchanged)
~1–8 weeks in N weeks[, M days] — e.g. in 2 weeks, 3 days, in 1 week
beyond ~2 months in N months

Exact cutover points (when weeks flip to months) are an implementation call — flag it in the PR rather than blocking on it here. Keep the future and past branches symmetric so the two sides of the timeline read consistently.

Where to change it

  • frontend/src/utils/formatUtils.ts:78-104 (formatDueAt) — extend both the diffDays < -6 branch (currently uncapped N weeks ago) and the diffDays > 6 branch (currently jumps straight to the absolute-date fallback) with the weeks[, days]/months cases described above. Keep an absolute-date fallback for whatever's left beyond the month cap on the future side (past side can just keep counting months, matching how "N weeks ago" currently never caps).
  • frontend/src/utils/formatUtils.test.ts — add cases for the new week/month buckets on both sides (existing tests already cover Today/Tomorrow/Yesterday/in 3 days/3 days ago/2 weeks ago/absolute-date fallback).

Notes / scope

  • formatRewardDuration (same file, formatUtils.ts:36-57) already has a working pattern for singular/plural unit combination (hours + minutes) that's a reasonable model to follow for weeks + days.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions