Skip to content

Commit

Permalink
Make Calendar.id optional on plain objects, to align with TimeZone.id
Browse files Browse the repository at this point in the history
We have TimeZone.id optional on plain objects, in favour of requiring
TimeZone.toString(). The calendar protocol should do the same thing.
  • Loading branch information
ptomato committed Oct 22, 2020
1 parent 14ba0a4 commit df5d81c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The identifier of a custom calendar must consist of one or more components of be
### Protocol

It's also possible for a plain object to be a custom calendar, without subclassing.
The object must implement the `Temporal.Calendar` methods and have an `id` property.
The object must implement all of the `Temporal.Calendar` methods except for `fields()`.
It must not have a `calendar` property, so that it can be distinguished in `Temporal.Calendar.from()` from other Temporal objects that have a calendar.
It is possible to pass such an object into any Temporal API that would normally take a built-in `Temporal.Calendar`.

Expand Down
3 changes: 2 additions & 1 deletion polyfill/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export namespace Temporal {
}

export interface CalendarProtocol {
id: string;
id?: string;
calendar?: never;
year(date: Temporal.Date): number;
month(date: Temporal.Date): number;
Expand Down Expand Up @@ -484,6 +484,7 @@ export namespace Temporal {
| /** @deprecated */ 'day'
>
): Temporal.Duration;
toString(): string;
}

/**
Expand Down

0 comments on commit df5d81c

Please sign in to comment.