From 5721bccede0d5fab4d7b91677e115f81a55d0874 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 5 Dec 2024 00:40:37 +0800 Subject: [PATCH] fix duration --- src/duration.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/duration.ts b/src/duration.ts index 77de611..5abf035 100644 --- a/src/duration.ts +++ b/src/duration.ts @@ -182,6 +182,9 @@ export function roundToSingleUnit(duration: Duration, {relativeTo = Date.now()}: } else if (monthsDiff < 11) { months = monthsDiff years = 0 + } else if (monthsDiff === 11) { + months = 0 + years += 1 // the old behavior: "11 months" is rounded to "1 year" } else { months = 0 years = yearDiff * sign