From 197c7c9e2507f3a68a047afc673fdb4f8bd81f89 Mon Sep 17 00:00:00 2001 From: fabon Date: Thu, 10 Oct 2024 13:55:44 +0900 Subject: [PATCH] Reject PlainYearMonth with different calendar in comparison --- src/datetime/_compare.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/datetime/_compare.ts b/src/datetime/_compare.ts index d39c143..0aa0023 100644 --- a/src/datetime/_compare.ts +++ b/src/datetime/_compare.ts @@ -56,6 +56,9 @@ export function compare(a: ComparableDateTimeType, b: ComparableDateTimeType) { return getConstructor(a).compare(a, b); } if (isPlainYearMonth(a) && isPlainYearMonth(b)) { + if (a.calendarId !== b.calendarId) { + throw new Error("Can't compare PlainYearMonth with different calendar"); + } return getConstructor(a).compare(a, b); } if (isPlainMonthDay(a) || isPlainMonthDay(b)) {