Overview
Create utility for displaying relative time.
Parent Epic: #70
Priority: P1
Prerequisites
Next Issues (after this is complete)
- Can be used by Story and Comment components
Acceptance Criteria
Implementation Notes
export function timeAgo(timestamp: number): string {
const seconds = Math.floor(Date.now() / 1000 - timestamp);
if (seconds < 60) return 'just now';
if (seconds < 3600) return `${Math.floor(seconds / 60)} minutes ago`;
if (seconds < 86400) return `${Math.floor(seconds / 3600)} hours ago`;
return `${Math.floor(seconds / 86400)} days ago`;
}
Note: This could also be done server-side in Ruby (in the presenters). Decide based on where it's most useful.
Overview
Create utility for displaying relative time.
Parent Epic: #70
Priority: P1
Prerequisites
Next Issues (after this is complete)
Acceptance Criteria
app/javascript/lib/timeAgo.tscreatedImplementation Notes
Note: This could also be done server-side in Ruby (in the presenters). Decide based on where it's most useful.