diff --git a/polyfill/lib/plaindate.mjs b/polyfill/lib/plaindate.mjs index ba5004a5bd..9858e51752 100644 --- a/polyfill/lib/plaindate.mjs +++ b/polyfill/lib/plaindate.mjs @@ -438,7 +438,7 @@ export class PlainDate { static compare(one, two) { one = ES.ToTemporalDate(one, PlainDate); two = ES.ToTemporalDate(two, PlainDate); - const result = ES.CompareISODate( + return ES.CompareISODate( GetSlot(one, ISO_YEAR), GetSlot(one, ISO_MONTH), GetSlot(one, ISO_DAY), @@ -446,8 +446,6 @@ export class PlainDate { GetSlot(two, ISO_MONTH), GetSlot(two, ISO_DAY) ); - if (result !== 0) return result; - return ES.CalendarCompare(GetSlot(one, CALENDAR), GetSlot(two, CALENDAR)); } } diff --git a/polyfill/lib/plaindatetime.mjs b/polyfill/lib/plaindatetime.mjs index d2a3b2aa53..85ddca03e8 100644 --- a/polyfill/lib/plaindatetime.mjs +++ b/polyfill/lib/plaindatetime.mjs @@ -794,7 +794,7 @@ export class PlainDateTime { const val2 = GetSlot(two, slot); if (val1 !== val2) return ES.ComparisonResult(val1 - val2); } - return ES.CalendarCompare(GetSlot(one, CALENDAR), GetSlot(two, CALENDAR)); + return 0; } } diff --git a/polyfill/lib/plainyearmonth.mjs b/polyfill/lib/plainyearmonth.mjs index 9bd82c8cac..dbda28e838 100644 --- a/polyfill/lib/plainyearmonth.mjs +++ b/polyfill/lib/plainyearmonth.mjs @@ -396,12 +396,14 @@ export class PlainYearMonth { static compare(one, two) { one = ES.ToTemporalYearMonth(one, PlainYearMonth); two = ES.ToTemporalYearMonth(two, PlainYearMonth); - for (const slot of [ISO_YEAR, ISO_MONTH, ISO_DAY]) { - const val1 = GetSlot(one, slot); - const val2 = GetSlot(two, slot); - if (val1 !== val2) return ES.ComparisonResult(val1 - val2); - } - return ES.CalendarCompare(GetSlot(one, CALENDAR), GetSlot(two, CALENDAR)); + return ES.CompareISODate( + GetSlot(one, ISO_YEAR), + GetSlot(one, ISO_MONTH), + GetSlot(one, ISO_DAY), + GetSlot(two, ISO_YEAR), + GetSlot(two, ISO_MONTH), + GetSlot(two, ISO_DAY) + ); } } diff --git a/polyfill/lib/zoneddatetime.mjs b/polyfill/lib/zoneddatetime.mjs index d11ed7f69c..49714444ff 100644 --- a/polyfill/lib/zoneddatetime.mjs +++ b/polyfill/lib/zoneddatetime.mjs @@ -861,8 +861,6 @@ export class ZonedDateTime { const ns2 = GetSlot(two, EPOCHNANOSECONDS); if (bigInt(ns1).lesser(ns2)) return -1; if (bigInt(ns1).greater(ns2)) return 1; - const calendarResult = ES.CalendarCompare(GetSlot(one, CALENDAR), GetSlot(two, CALENDAR)); - if (calendarResult) return calendarResult; return ES.TimeZoneCompare(GetSlot(one, TIME_ZONE), GetSlot(two, TIME_ZONE)); } } diff --git a/polyfill/test/PlainDate/constructor/compare/use-internal-slots.js b/polyfill/test/PlainDate/constructor/compare/use-internal-slots.js index 8f885b9893..4c21cd540b 100644 --- a/polyfill/test/PlainDate/constructor/compare/use-internal-slots.js +++ b/polyfill/test/PlainDate/constructor/compare/use-internal-slots.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal-comparetemporaldate +esid: sec-temporal-compareisodate ---*/ function CustomError() {} diff --git a/polyfill/test/PlainDateTime/constructor/compare/use-internal-slots.js b/polyfill/test/PlainDateTime/constructor/compare/use-internal-slots.js index 7fb9f3e5e1..f6b1e10885 100644 --- a/polyfill/test/PlainDateTime/constructor/compare/use-internal-slots.js +++ b/polyfill/test/PlainDateTime/constructor/compare/use-internal-slots.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal-comparetemporaldatetime +esid: sec-temporal-compareisodatetime ---*/ function CustomError() {} diff --git a/polyfill/test/zoneddatetime.mjs b/polyfill/test/zoneddatetime.mjs index 5efcd414dd..634552bddc 100644 --- a/polyfill/test/zoneddatetime.mjs +++ b/polyfill/test/zoneddatetime.mjs @@ -2813,8 +2813,8 @@ describe('ZonedDateTime', () => { it('compares time zone IDs if exact times are equal', () => { equal(ZonedDateTime.compare(zdt1, zdt1.withTimeZone('Asia/Kolkata')), 1); }); - it('compares calendar IDs if exact times and time zones are equal', () => { - equal(ZonedDateTime.compare(zdt1, zdt1.withCalendar('japanese')), -1); + it('disregards calendar IDs if exact times and time zones are equal', () => { + equal(ZonedDateTime.compare(zdt1, zdt1.withCalendar('japanese')), 0); }); it('compares exact time, not clock time', () => { const clockBefore = ZonedDateTime.from('1999-12-31T23:30-08:00[America/Vancouver]');