Skip to content

feat(time-utils): add formatRelativeTimeLabel with injectable now param#505

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
wheval:feat/relative-time-label-util
Jun 27, 2026
Merged

feat(time-utils): add formatRelativeTimeLabel with injectable now param#505
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
wheval:feat/relative-time-label-util

Conversation

@wheval

@wheval wheval commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Adds formatRelativeTimeLabel(date: Date, now?: Date): string to src/utils/time.utils.ts.

Behavior:

Elapsed Output
< 60 s just now
< 60 min N minutes ago
< 24 h N hours ago
< 30 days N days ago
≥ 30 days formatted date e.g. 12 Jan 2026

The now parameter is injectable (defaults to new Date()) for deterministic unit testing. Includes tests for every boundary in src/utils/__tests__/time.utils.test.ts.

Closes #477

Returns human-readable relative labels with a 30-day cutoff:
< 60s → "just now", < 60m → "N minutes ago", < 24h → "N hours ago",
< 30d → "N days ago", ≥ 30d → formatted date ("12 Jan 2026").
Includes unit tests covering every boundary and the default-now path.

Closes accesslayerorg#477
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@wheval Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit aed40df into accesslayerorg:dev Jun 27, 2026
1 check passed
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.

Add helper for formatting relative time labels for activity feed timestamps

2 participants