Skip to content

Commit

Permalink
Add Gregorian calendar
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ptomato committed Jun 10, 2020
1 parent 073995c commit b482707
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions polyfill/lib/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
3 changes: 2 additions & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit b482707

Please sign in to comment.