Skip to content

Commit 0e22325

Browse files
authored
Update Temporal.Calendar docs
Adjust docs for Temporal.Calendar for a few reasons: * Account for #2574 which stops coercing non-string inputs * Fix inaccurate claims in the constructor docs * Reorganize sample code for `from` for clarity
1 parent 9eb39e1 commit 0e22325

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/calendar.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ For a list of calendar identifiers, see the documentation for [Intl.DateTimeForm
175175
If `calendarIdentifier` is not a built-in calendar, then a `RangeError` is thrown.
176176

177177
Use this constructor directly if you have a string that is known to be a correct built-in calendar identifier.
178-
If you have an ISO 8601 date-time string with a `[u-ca=identifier]` annotation, then `Temporal.Calendar.from()` is more convenient than parsing the identifier out of the string, and also the only way to parse strings annotated with a non-built-in calendar.
178+
If you have an ISO 8601 date-time string with a `[u-ca=identifier]` annotation, then `Temporal.Calendar.from()` is more convenient than parsing the identifier out of the string.
179179

180180
Example usage:
181181

@@ -199,9 +199,9 @@ This static method creates a new calendar from another value.
199199
If the value is another `Temporal.Calendar` object, or object implementing the calendar protocol, the same object is returned.
200200
If the value is another Temporal object that carries a calendar or an object with a `calendar` property, such as a `Temporal.ZonedDateTime`, the object's calendar is returned.
201201

202-
Any other value is converted to a string, which is expected to be either:
202+
Any other value is required to be a string that is either:
203203

204-
- a string that is accepted by `new Temporal.Calendar()`; or
204+
- a calendar idenfier accepted by `new Temporal.Calendar()`; or
205205
- a string in the ISO 8601 format.
206206

207207
Note that the ISO 8601 string can be extended with a `[u-ca=identifier]` annotation in square brackets appended to it.
@@ -219,13 +219,13 @@ cal = Temporal.Calendar.from('gregory');
219219
// ISO 8601 string with or without calendar annotation
220220
cal = Temporal.Calendar.from('2020-01-13T16:31:00.065858086');
221221
cal = Temporal.Calendar.from('2020-01-13T16:31:00.065858086-08:00[America/Vancouver][u-ca=iso8601]');
222+
/* WRONG */ cal = Temporal.Calendar.from('[u-ca-iso8601]'); // => throws, lone annotation not a valid ISO 8601 string
222223

223224
// Existing calendar object
224225
cal2 = Temporal.Calendar.from(cal);
225226

226-
// Custom calendar that is a plain object (this calendar does not do much)
227+
// Custom calendar names cannot be parsed from strings
227228
/* WRONG */ cal = Temporal.Calendar.from('discordian'); // => throws, not a built-in calendar
228-
/* WRONG */ cal = Temporal.Calendar.from('[u-ca-iso8601]'); // => throws, lone annotation not a valid ISO 8601 string
229229
```
230230

231231
## Properties

0 commit comments

Comments
 (0)