Skip to content

Commit eeade77

Browse files
Fix micro format tense logic to allow month durations through
Co-authored-by: francinelucca <[email protected]>
1 parent 7bf7225 commit eeade77

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/relative-time-element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
170170
if (format === 'micro') {
171171
duration = roundToSingleUnit(duration)
172172
empty = microEmptyDuration
173-
if ((this.tense === 'past' && duration.sign !== -1) || (this.tense === 'future' && duration.sign !== 1)) {
173+
// Allow month-level durations to pass through even with mismatched tense
174+
if (
175+
duration.months === 0 &&
176+
((this.tense === 'past' && duration.sign !== -1) || (this.tense === 'future' && duration.sign !== 1))
177+
) {
174178
duration = microEmptyDuration
175179
}
176180
} else if ((tense === 'past' && duration.sign !== -1) || (tense === 'future' && duration.sign !== 1)) {

0 commit comments

Comments
 (0)