From 4201e5910531d668ab614147d0f95e243c532367 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 7 Oct 2020 11:53:12 -0700 Subject: [PATCH] Fix documentation of era property in from() methods Closes: #902 --- docs/date.md | 6 +++++- docs/datetime.md | 10 +++++++--- docs/monthday.md | 2 ++ docs/yearmonth.md | 7 ++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/docs/date.md b/docs/date.md index 820a1a76fb..83656f59fb 100644 --- a/docs/date.md +++ b/docs/date.md @@ -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`. diff --git a/docs/datetime.md b/docs/datetime.md index 51fee27ca2..d2180ae9ad 100644 --- a/docs/datetime.md +++ b/docs/datetime.md @@ -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. diff --git a/docs/monthday.md b/docs/monthday.md index 9e252ff1c1..b9aac675f7 100644 --- a/docs/monthday.md +++ b/docs/monthday.md @@ -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`. diff --git a/docs/yearmonth.md b/docs/yearmonth.md index 42e7b05dd5..6ed879699d 100644 --- a/docs/yearmonth.md +++ b/docs/yearmonth.md @@ -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.