* Format a date as relative time (e.g., "2 hours ago", "3 days ago")
(date: Date)
| 56 | * Format a date as relative time (e.g., "2 hours ago", "3 days ago") |
| 57 | */ |
| 58 | function formatRelativeTime(date: Date): string { |
| 59 | const now = new Date(); |
| 60 | const diffMs = now.getTime() - date.getTime(); |
| 61 | const diffSecs = Math.floor(diffMs / 1000); |
| 62 | const diffMins = Math.floor(diffSecs / 60); |
| 63 | const diffHours = Math.floor(diffMins / 60); |
| 64 | const diffDays = Math.floor(diffHours / 24); |
| 65 | |
| 66 | if (diffDays > 30) { |
| 67 | return date.toLocaleDateString(); |
| 68 | } else if (diffDays > 0) { |
| 69 | return `${diffDays}d ago`; |
| 70 | } else if (diffHours > 0) { |
| 71 | return `${diffHours}h ago`; |
| 72 | } else if (diffMins > 0) { |
| 73 | return `${diffMins}m ago`; |
| 74 | } else { |
| 75 | return 'just now'; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | export class ListCommand { |
| 80 | async execute(targetPath: string = '.', mode: 'changes' | 'specs' = 'changes', options: ListOptions = {}): Promise<void> { |