diff --git a/docs/zoneddatetime.md b/docs/zoneddatetime.md index 5744c02499..04ee8f89ab 100644 --- a/docs/zoneddatetime.md +++ b/docs/zoneddatetime.md @@ -1245,7 +1245,7 @@ zdt1.equals(zdt1); // => true Valid values are `'auto'` and `'never'`. The default is `'auto'`. - `timeZoneName` (string): Whether to show the time zone name annotation in the return value. - Valid values are `'auto'` and `'never'`. + Valid values are `'auto'`, `'never'`, and `'critical'`. The default is `'auto'`. - `calendarName` (string): Whether to show the calendar annotation in the return value. Valid values are `'auto'`, `'always'`, `'never'`, and `'critical'`. @@ -1284,8 +1284,9 @@ For more information on the calendar annotation, see [ISO string extensions](./s Likewise, passing `'never'` to the `timeZoneName` or `offset` options controls whether the time zone offset (`+01:00`) or name annotation (`[Europe/Paris]`) are shown. If the time zone offset is shown, it is always shown rounded to the nearest minute. +The `timeZoneName` option can additionally be `'critical'` which will add an additional `!` to the annotation, similar to `calendarName`. -The string format output by this method can be parsed by [`java.time.ZonedDateTime`](https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html) as long as the calendar annotation is not output. +The string format output by this method can be parsed by [`java.time.ZonedDateTime`](https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html) as long as the calendar annotation is not output and `'critical'` is not used. For more information on `Temporal`'s extensions to the ISO 8601 / RFC 3339 string format and the progress towards becoming a published standard, see [String Parsing, Serialization, and Formatting](./strings.md). Example usage: diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index eba28fac11..216f591b40 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -722,7 +722,7 @@ export const ES = ObjectAssign({}, ES2020, { return ES.GetOption(options, 'calendarName', ['auto', 'always', 'never', 'critical'], 'auto'); }, ToShowTimeZoneNameOption: (options) => { - return ES.GetOption(options, 'timeZoneName', ['auto', 'never'], 'auto'); + return ES.GetOption(options, 'timeZoneName', ['auto', 'never', 'critical'], 'auto'); }, ToShowOffsetOption: (options) => { return ES.GetOption(options, 'offset', ['auto', 'never'], 'auto'); @@ -2146,7 +2146,10 @@ export const ES = ObjectAssign({}, ES2020, { const offsetNs = ES.GetOffsetNanosecondsFor(tz, instant); result += ES.FormatISOTimeZoneOffsetString(offsetNs); } - if (showTimeZone !== 'never') result += `[${tz}]`; + if (showTimeZone !== 'never') { + const flag = showTimeZone === 'critical' ? '!' : ''; + result += `[${flag}${tz}]`; + } result += ES.MaybeFormatCalendarAnnotation(GetSlot(zdt, CALENDAR), showCalendar); return result; }, diff --git a/spec/abstractops.html b/spec/abstractops.html index 938ecbce5f..7a60bdd4bb 100644 --- a/spec/abstractops.html +++ b/spec/abstractops.html @@ -162,7 +162,7 @@