MCPcopy
hub / github.com/claude-code-best/claude-code / formatRelativeTimeAgo

Function formatRelativeTimeAgo

src/utils/format.ts:186–198  ·  view source on GitHub ↗
(
  date: Date,
  options: RelativeTimeOptions & { now?: Date } = {},
)

Source from the content-addressed store, hash-verified

184}
185
186export 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)

Callers 8

format.test.tsFile · 0.90
SessionPreviewFunction · 0.85
MessageSelectorFunction · 0.85
HistorySearchDialogFunction · 0.85
MemoryFileSelectorFunction · 0.85
createRecentActivityFeedFunction · 0.85
formatLogMetadataFunction · 0.85
buildDeepLinkBannerFunction · 0.85

Calls 1

formatRelativeTimeFunction · 0.70

Tested by

no test coverage detected