(
date: Date,
options: RelativeTimeOptions & { now?: Date } = {},
)
| 184 | } |
| 185 | |
| 186 | export function formatRelativeTimeAgo( |
| 187 | date: Date, |
| 188 | options: RelativeTimeOptions & { now?: Date } = {}, |
| 189 | ): string { |
| 190 | const { now = new Date(), ...restOptions } = options |
| 191 | if (date > now) { |
| 192 | // For future dates, just return the relative time without "ago" |
| 193 | return formatRelativeTime(date, { ...restOptions, now }) |
| 194 | } |
| 195 | |
| 196 | // For past dates, force numeric: 'always' to ensure we get "X units ago" |
| 197 | return formatRelativeTime(date, { ...restOptions, numeric: 'always', now }) |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Formats log metadata for display (time, size or message count, branch, tag, PR) |
no test coverage detected