From b482707c47d524856608a0a13fd3522cd4b68680 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 10 Jun 2020 15:31:36 -0700 Subject: [PATCH] Add Gregorian calendar This is identical to the ISO8601 calendar, except for ISO week numbering rules, which we do not currently use in Temporal. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar --- polyfill/lib/calendar.mjs | 9 +++++++++ polyfill/lib/ecmascript.mjs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/polyfill/lib/calendar.mjs b/polyfill/lib/calendar.mjs index 3682b6f2f0..480eb054b1 100644 --- a/polyfill/lib/calendar.mjs +++ b/polyfill/lib/calendar.mjs @@ -203,3 +203,12 @@ export class ISO8601 extends Calendar { return ES.LeapYear(GetSlot(date, ISO_YEAR)); } } + +// According to documentation for Intl.Locale.prototype.calendar on MDN, +// 'iso8601' calendar is equivalent to 'gregory' except for ISO 8601 week +// numbering rules, which we do not currently use in Temporal. +export class Gregorian extends ISO8601 { + constructor() { + super('gregory'); + } +} diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index d6aee90d84..6a785d20d8 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -6,7 +6,7 @@ const ObjectAssign = Object.assign; import bigInt from 'big-integer'; import { GetIntrinsic } from './intrinsicclass.mjs'; -import { ISO8601 as CalendarISO8601 } from './calendar.mjs'; +import { Gregorian as CalendarGregorian, ISO8601 as CalendarISO8601 } from './calendar.mjs'; import { GetSlot, HasSlot, @@ -43,6 +43,7 @@ const YEAR_MIN = -271821; const YEAR_MAX = 275760; const BUILTIN_CALENDARS = { + gregory: CalendarGregorian, iso8601: CalendarISO8601 // To be filled in as builtin calendars are implemented };