Skip to content

Commit

Permalink
Reject PlainYearMonth with different calendar in comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
fabon-f committed Oct 10, 2024
1 parent c1ba1f1 commit 197c7c9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/datetime/_compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 197c7c9

Please sign in to comment.