Skip to content

dateUtils: Add formatRelative function for human-readable relative dates #701

Description

@Kingsman-99

Description

dateUtils provides absolute date formatting but no relative formatting. Contributors should add a formatRelative(date: Date, now?: Date): string function that returns human-readable strings like "just now", "2 minutes ago", "3 days ago", and "in 5 hours", capped at "over a year ago" / "over a year from now" for distant dates.

Acceptance Criteria

  • formatRelative returns "just now" for dates within 60 seconds of now
  • It returns minute, hour, day, week, and month variants as appropriate
  • It accepts an optional now parameter (defaults to new Date()) for testability
  • Existing tests continue to pass

Context

  • Target file: src/lib/dateUtils.ts
  • Do not import any third-party date library — implement purely with native Date arithmetic

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions