mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 10:16:49 +00:00
- create utils/time.ts for centralized time formatting - remove duplicate from auth/commands/types.ts - re-export for backward compatibility - export from utils/index.ts
23 lines
549 B
TypeScript
23 lines
549 B
TypeScript
/**
|
|
* Time Formatting Utilities
|
|
*
|
|
* Centralized date/time formatting functions.
|
|
*/
|
|
|
|
/**
|
|
* Format relative time (e.g., "2h ago", "1d ago")
|
|
*/
|
|
export function formatRelativeTime(date: Date): string {
|
|
const now = Date.now();
|
|
const diff = now - date.getTime();
|
|
|
|
const minutes = Math.floor(diff / 60000);
|
|
const hours = Math.floor(diff / 3600000);
|
|
const days = Math.floor(diff / 86400000);
|
|
|
|
if (days > 0) return `${days}d ago`;
|
|
if (hours > 0) return `${hours}h ago`;
|
|
if (minutes > 0) return `${minutes}m ago`;
|
|
return 'just now';
|
|
}
|