Skip to content

Add formatRelativeTime helper for activity feed timestamps#517

Closed
wheval wants to merge 1 commit into
accesslayerorg:mainfrom
wheval:feat/relative-time-helper
Closed

Add formatRelativeTime helper for activity feed timestamps#517
wheval wants to merge 1 commit into
accesslayerorg:mainfrom
wheval:feat/relative-time-helper

Conversation

@wheval

@wheval wheval commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a shared formatRelativeTime(date, now?) utility and comprehensive unit tests covering all time-range boundaries.

Changes

  • src/utils/relativeTime.utils.ts — new helper
    • < 60s → just now
    • < 60m → N minute(s) ago
    • < 24h → N hour(s) ago
    • < 30d → N day(s) ago
    • ≥ 30d → formatted date string (12 Jan 2026)
    • Injectable now param for deterministic tests
  • src/utils/__tests__/relativeTime.utils.test.ts — unit tests for every boundary and singular/plural form

Closes #477

- formatRelativeTime(date, now?): 'just now' | 'N minutes ago' | 'N hours ago' | 'N days ago' | formatted date
- Boundaries: <60s → just now, <60m → minutes, <24h → hours, <30d → days, ≥30d → 'DD Mon YYYY'
- Injectable now param for deterministic unit tests
- Unit tests covering all time range boundaries and singular/plural forms

Closes accesslayerorg#477
@github-actions

Copy link
Copy Markdown

👋 Hey @wheval, thanks for your contribution!

This PR is targeting main directly. We use main for stable releases only — all contributions should be opened against the dev branch instead.

Please close this PR and reopen it with dev as the base branch. If you're unsure how to do that, you can change the base branch using the Edit button at the top of this PR page.

Closing this PR automatically. See you in dev! 🚀

@github-actions github-actions Bot closed this Jun 29, 2026
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for accesslayer ready!

Name Link
🔨 Latest commit 42a6f7e
🔍 Latest deploy log https://app.netlify.com/projects/accesslayer/deploys/6a42c9f21b4d070008d88c23
😎 Deploy Preview https://deploy-preview-517--accesslayer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant