Skip to content

Commit

Permalink
Fix documentation of era property in from() methods
Browse files Browse the repository at this point in the history
Closes: #902
  • Loading branch information
ptomato authored and ryzokuken committed Oct 7, 2020
1 parent 2775112 commit 4201e59
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion docs/date.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ date = new Temporal.Date(2020, 3, 14); // => 2020-03-14

This static method creates a new `Temporal.Date` object from another value.
If the value is another `Temporal.Date` object, a new object representing the same date is returned.
If the value is any other object, it must have `year`, `month`, and `day` properties, and optionally a `calendar` property.
If the value is any other object, it must have `year`, `month`, and `day` properties, and optionally `era` and `calendar` properties.
If `calendar` is a calendar that requires `era` (such as the Japanese calendar), then the `era` property must also be present.
A `Temporal.Date` will be constructed from these properties.

If the `calendar` property is not present, it will be assumed to be `Temporal.Calendar.from('iso8601')`, the [ISO 8601 calendar](https://en.wikipedia.org/wiki/ISO_8601#Dates).
In this calendar, `era` is ignored.

Any non-object value is converted to a string, which is expected to be in ISO 8601 format.
Any time or time zone part is optional and will be ignored.
If the string isn't valid according to ISO 8601, then a `RangeError` will be thrown regardless of the value of `overflow`.
Expand Down
10 changes: 7 additions & 3 deletions docs/datetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ datetime = new Temporal.DateTime(2020, 3, 14, 13, 37); // => 2020-03-14T13:37

This static method creates a new `Temporal.DateTime` object from another value.
If the value is another `Temporal.DateTime` object, a new object representing the same date and time is returned.
If the value is any other object, a `Temporal.DateTime` will be constructed from the values of any `year`, `month`, `day`, `hour`, `minute`, `second`, `millisecond`, `microsecond`, `nanosecond`, and `calendar` properties that are present.
If the value is any other object, a `Temporal.DateTime` will be constructed from the values of any `era`, `year`, `month`, `day`, `hour`, `minute`, `second`, `millisecond`, `microsecond`, `nanosecond`, and `calendar` properties that are present.

At least the `year`, `month`, and `day` properties must be present.
If `calendar` is missing, it will be assumed to be `Temporal.Calendar.from('iso8601')`.
Any other missing ones will be assumed to be 0.
If `calendar` is a calendar that requires `era` (such as the Japanese calendar), then the `era` property must also be present.
Default values for other missing fields are determined by the calendar.

If the `calendar` property is not present, it will be assumed to be `Temporal.Calendar.from('iso8601')`, the [ISO 8601 calendar](https://en.wikipedia.org/wiki/ISO_8601#Dates).
In this calendar, `era` is ignored, and the default values for other missing fields are all 0.

Any non-object value is converted to a string, which is expected to be in ISO 8601 format.
Any time zone part is optional and will be ignored.
Expand Down
2 changes: 2 additions & 0 deletions docs/monthday.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ This static method creates a new `Temporal.MonthDay` object from another value.
If the value is another `Temporal.MonthDay` object, a new object representing the same month and day is returned.
If the value is any other object, it must have `month` and `day` properties, and optionally a `calendar` property, and a `Temporal.MonthDay` will be constructed from these properties.

If the `calendar` property is not present, it will be assumed to be `Temporal.Calendar.from('iso8601')`, the [ISO 8601 calendar](https://en.wikipedia.org/wiki/ISO_8601#Dates).

Any non-object value will be converted to a string, which is expected to be in ISO 8601 format.
Any parts of the string other than the month and the day are optional and will be ignored.
If the string isn't valid according to ISO 8601, then a `RangeError` will be thrown regardless of the value of `overflow`.
Expand Down
7 changes: 6 additions & 1 deletion docs/yearmonth.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ ym = new Temporal.YearMonth(2019, 6) // => 2019-06

This static method creates a new `Temporal.YearMonth` object from another value.
If the value is another `Temporal.YearMonth` object, a new object representing the same month is returned.
If the value is any other object, it must have `year` and `month` properties, and a `Temporal.YearMonth` will be constructed from them.
If the value is any other object, it must have `year` and `month` properties, and optionally `era` and `calendar` properties.
If `calendar` is a calendar that requires `era` (such as the Japanese calendar), then the `era` property must also be present.
A `Temporal.YearMonth` will be constructed from these properies.

If the `calendar` property is not present, it will be assumed to be `Temporal.Calendar.from('iso8601')`, the [ISO 8601 calendar](https://en.wikipedia.org/wiki/ISO_8601#Dates).
In this calendar, `era` is ignored.

Any non-object value is converted to a string, which is expected to be in ISO 8601 format.
Any parts of the string other than the year and the month are optional and will be ignored.
Expand Down

0 comments on commit 4201e59

Please sign in to comment.