MCPcopy Index your code
hub / github.com/github/relative-time-element / getRelativeTimeUnit

Function getRelativeTimeUnit

src/duration.ts:221–233  ·  view source on GitHub ↗
(
  duration: Duration,
  opts?: Partial<RoundingOpts>,
)

Source from the content-addressed store, hash-verified

219}
220
221export function getRelativeTimeUnit(
222 duration: Duration,
223 opts?: Partial<RoundingOpts>,
224): [number, Intl.RelativeTimeFormatUnit] {
225 const rounded = roundToSingleUnit(duration, opts)
226 if (rounded.blank) return [0, 'second']
227 for (const unit of unitNames) {
228 if (unit === 'millisecond') continue
229 const val = rounded[`${unit}s` as keyof Duration] as number
230 if (val) return [val, unit]
231 }
232 return [0, 'second']
233}

Callers 3

duration.tsFile · 0.90
#getRelativeFormatMethod · 0.85

Calls 1

roundToSingleUnitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…