( duration: Duration, opts?: Partial<RoundingOpts>, )
| 219 | } |
| 220 | |
| 221 | export 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 | } |
no test coverage detected
searching dependent graphs…