-
Notifications
You must be signed in to change notification settings - Fork 185
Closed
Description
https://jsfiddle.net/oabcw7mz/ has an example of trying to render (now - 23 hours) with a precision of days, which should show "today" but actually shows "now".
I think the fix will involve making getRelativeTimeUnit
relative-time-element/src/duration.ts
Lines 206 to 218 in a0483ce
export function getRelativeTimeUnit( | |
duration: Duration, | |
opts?: Partial<RoundingOpts>, | |
): [number, Intl.RelativeTimeFormatUnit] { | |
const rounded = roundToSingleUnit(duration, opts) | |
if (rounded.blank) return [0, 'second'] | |
for (const unit of unitNames) { | |
if (unit === 'millisecond') continue | |
const val = rounded[`${unit}s` as keyof Duration] as number | |
if (val) return [val, unit] | |
} | |
return [0, 'second'] | |
} |
return the precision
unit for empty durations.
Metadata
Metadata
Assignees
Labels
No labels
Activity
keithamus commentedon Mar 26, 2024
Sounds like you have a good handle on the problem. Would you like to make a PR?