Skip to content

Commit

Permalink
Sync calendar annotation format with the IETF draft
Browse files Browse the repository at this point in the history
IETF is moving forward with [n-kk=vvvvv] (n=namespace, k=key, v=value)
rather than [n-kk-vvvvv]. By definition, Temporal uses the format that is
being standardized within IETF.

Update the note in the spec text as well to remove the text saying that
the format is tentative. This is the format that IETF is moving forward
with.

Closes: #1409
Closes: #1412
  • Loading branch information
ptomato committed Mar 19, 2021
1 parent 4a1f98e commit fa38136
Show file tree
Hide file tree
Showing 31 changed files with 175 additions and 201 deletions.
2 changes: 1 addition & 1 deletion docs/ambiguity.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ zdt = instant.toZonedDateTime('Asia/Tokyo', 'iso8601').toLocaleString('ja-jp', f
// this is identical to the result of toZonedDateTime() above

zdt = instant.toZonedDateTime('Asia/Tokyo', 'japanese');
// => 2019-09-03T17:34:05+09:00[Asia/Tokyo][u-ca-japanese]
// => 2019-09-03T17:34:05+09:00[Asia/Tokyo][u-ca=japanese]
zdt.toLocaleString('en-us', { ...formatOptions, calendar: zdt.calendar });
// => "Sep 3, 1 Reiwa, 5:34:05 PM"
zdt.year;
Expand Down
16 changes: 8 additions & 8 deletions docs/calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ For a list of calendar identifiers, see the documentation for [Intl.DateTimeForm
If `calendarIdentifier` is not a built-in calendar, then a `RangeError` is thrown.

Use this constructor directly if you have a string that is known to be a correct built-in calendar identifier.
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.
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.

Example usage:

Expand Down Expand Up @@ -146,7 +146,7 @@ Any other value is converted to a string, which is expected to be either:
- a string that is accepted by `new Temporal.Calendar()`; or
- a string in the ISO 8601 format.

Note that the ISO 8601 string can be extended with a `[u-ca-identifier]` annotation in square brackets appended to it.
Note that the ISO 8601 string can be extended with a `[u-ca=identifier]` annotation in square brackets appended to it.
Without such an annotation, the calendar is taken to be `iso8601`.

This function is often more convenient to use than `new Temporal.Calendar()` because it handles a wider range of input.
Expand All @@ -160,7 +160,7 @@ cal = Temporal.Calendar.from('gregory');

// ISO 8601 string with or without calendar annotation
cal = Temporal.Calendar.from('2020-01-13T16:31:00.065858086');
cal = Temporal.Calendar.from('2020-01-13T16:31:00.065858086-08:00[America/Vancouver][u-ca-iso8601]');
cal = Temporal.Calendar.from('2020-01-13T16:31:00.065858086-08:00[America/Vancouver][u-ca=iso8601]');

// Existing calendar object
cal2 = Temporal.Calendar.from(cal);
Expand All @@ -169,7 +169,7 @@ cal2 = Temporal.Calendar.from(cal);
cal = Temporal.Calendar.from({ id: 'mycalendar' });

/*⚠️*/ cal = Temporal.Calendar.from('discordian'); // not a built-in calendar, throws
/*⚠️*/ cal = Temporal.Calendar.from('[u-ca-iso8601]'); // lone annotation not a valid ISO 8601 string
/*⚠️*/ cal = Temporal.Calendar.from('[u-ca=iso8601]'); // lone annotation not a valid ISO 8601 string
```

## Properties
Expand Down Expand Up @@ -273,7 +273,7 @@ date.year; // => 5779
date.month; // => 6
date.monthCode; // => "M05L"
date.day; // => 18
date.toString(); // => 2019-02-23[u-ca-hebrew]
date.toString(); // => 2019-02-23[u-ca=hebrew]
date.toLocaleString('en-US', { calendar: 'hebrew' }); // => "18 Adar I 5779"

// same result, but calling the method directly and using month index instead of month code:
Expand Down Expand Up @@ -320,7 +320,7 @@ date = Temporal.PlainDate.from('2020-05-29')
date.year; // => 1441
date.month; // => 11
date.day; // => 7
date.toString(); // => 2020-06-28[u-ca-islamic]
date.toString(); // => 2020-06-28[u-ca=islamic]

// same result, but calling the method directly:
date = Temporal.Calendar.from('islamic').dateAdd(
Expand All @@ -332,7 +332,7 @@ date = Temporal.Calendar.from('islamic').dateAdd(
date.year; // => 1441
date.month; // => 11
date.day; // => 7
date.toString(); // => 2020-06-28[u-ca-islamic]
date.toString(); // => 2020-06-28[u-ca=islamic]
```

### calendar.**dateUntil**(_one_: Temporal.PlainDate | object | string, _two_: Temporal.PlainDate | object | string, _options_: object) : Temporal.Duration
Expand Down Expand Up @@ -445,7 +445,7 @@ This method overrides `Object.prototype.toString()` and provides the calendar's
Example usage:

```javascript
Temporal.PlainDate.from('2020-05-29[u-ca-gregory]').calendar.toString(); // => gregory
Temporal.PlainDate.from('2020-05-29[u-ca=gregory]').calendar.toString(); // => gregory
```

### calendar.**toJSON**() : string
Expand Down
4 changes: 2 additions & 2 deletions docs/instant.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ Example usage:
epoch = Temporal.Instant.fromEpochSeconds(0);
timeZone = Temporal.TimeZone.from('America/New_York');
epoch.toZonedDateTime({ timeZone, calendar: 'gregory' });
// => 1969-12-31T19:00-05:00[America/New_York][u-ca-gregory]
// => 1969-12-31T19:00-05:00[America/New_York][u-ca=gregory]

// What time was the Unix epoch in Tokyo in the Japanese calendar?
timeZone = Temporal.TimeZone.from('Asia/Tokyo');
calendar = Temporal.Calendar.from('japanese');
zdt = epoch.toZonedDateTime({ timeZone, calendar });
// => 1970-01-01T09:00+09:00[Asia/Tokyo][u-ca-japanese]
// => 1970-01-01T09:00+09:00[Asia/Tokyo][u-ca=japanese]
console.log(zdt.year, zdt.era);
// => 45 showa
```
Expand Down
4 changes: 2 additions & 2 deletions docs/iso-string-ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ _Calendar-specific dates are expressed as their equivalent date in the ISO calen
For example, when parsed, the following string would represent the date **28 Iyar 5780** in the Hebrew calendar:

```
2020-05-22[u-ca-hebrew]
2020-05-22[u-ca=hebrew]
```

The syntax of the calendar suffix is currently being proposed for standardization with the CalConnect and IETF Calsify standards bodies.
Expand Down Expand Up @@ -86,7 +86,7 @@ The list of calendar identifiers currently supported by CLDR is:
Example of a maximal length string containing both an IANA time zone name and a calendar system:

```
2020-05-22T07:19:35.356-04:00[America/Indiana/Indianapolis][u-ca-islamic-umalqura]
2020-05-22T07:19:35.356-04:00[America/Indiana/Indianapolis][u-ca=islamic-umalqura]
```

### Calendar-dependent YearMonth and MonthDay
Expand Down
4 changes: 2 additions & 2 deletions docs/persistence-model.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/plaindate.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ date = Temporal.PlainDate.from(Temporal.PlainDateTime.from('2006-08-24T15:43:27'
// => same as above; Temporal.PlainDateTime has year, month, and day properties

calendar = Temporal.Calendar.from('islamic');
date = Temporal.PlainDate.from({ year: 1427, month; 8, day: 1, calendar }); // => 2006-08-24[u-ca-islamic]
date = Temporal.PlainDate.from({ year: 1427, month; 8, day: 1, calendar }); // => 2006-08-24[u-ca=islamic]
date = Temporal.PlainDate.from({ year: 1427, month: 8, day: 1, calendar: 'islamic' });
// => same as above

Expand Down Expand Up @@ -185,7 +185,7 @@ date.month; // => 8
date.monthCode; // => "M08"
date.day; // => 24

date = Temporal.PlainDate.from('2019-02-23[u-ca-hebrew]');
date = Temporal.PlainDate.from('2019-02-23[u-ca=hebrew]');
date.year; // => 5779
date.month; // => 6
date.monthCode; // => "M05L"
Expand All @@ -207,7 +207,7 @@ As inputs to `from` or `with`, `era` and `eraYear` can be used instead of `year`
Unlike `year`, `eraYear` may decrease as time proceeds because some eras (like the BCE era in the Gregorian calendar) count years backwards.

```javascript
date = Temporal.PlainDate.from('-000015-01-01[u-ca-gregory]');
date = Temporal.PlainDate.from('-000015-01-01[u-ca=gregory]');
date.era;
// => "bce"
date.eraYear;
Expand Down Expand Up @@ -384,7 +384,7 @@ This method is the same as `date.with({ calendar })`, but may be more efficient.
Usage example:

```javascript
date = Temporal.PlainDate.from('2006-08-24[u-ca-japanese]');
date = Temporal.PlainDate.from('2006-08-24[u-ca=japanese]');
date.withCalendar('iso8601'); // => 2006-08-24
```

Expand Down
14 changes: 7 additions & 7 deletions docs/plaindatetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ dt = Temporal.PlainDateTime.from(Temporal.PlainDate.from('1995-12-07T03:24:30'))

calendar = Temporal.Calendar.from('hebrew');
dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar });
// => 1995-12-07T03:24:30[u-ca-hebrew]
// => 1995-12-07T03:24:30[u-ca=hebrew]
dt = Temporal.PlainDateTime.from({ year: 5756, month: 3, day: 14, hour: 3, minute: 24, second: 30, calendar: 'hebrew' });
// => same as above

Expand Down Expand Up @@ -277,7 +277,7 @@ dt.millisecond; // => 0
dt.microsecond; // => 3
dt.nanosecond; // => 500

dt = Temporal.PlainDate.from('2019-02-23T03:24:30.000003500[u-ca-hebrew]');
dt = Temporal.PlainDate.from('2019-02-23T03:24:30.000003500[u-ca=hebrew]');
dt.year; // => 5779
dt.month; // => 6
dt.monthCode; // => "M05L"
Expand Down Expand Up @@ -305,7 +305,7 @@ As inputs to `from` or `with`, `era` and `eraYear` can be used instead of `year`
Unlike `year`, `eraYear` may decrease as time proceeds because some eras (like the BCE era in the Gregorian calendar) count years backwards.

```javascript
date = Temporal.PlainDateTime.from('-000015-01-01T12:30[u-ca-gregory]');
date = Temporal.PlainDateTime.from('-000015-01-01T12:30[u-ca=gregory]');
date.era;
// => "bce"
date.eraYear;
Expand Down Expand Up @@ -536,9 +536,9 @@ dt.withPlainDate('2018-09-15'); // => 2018-09-15T03:24:30
dt.add({ hours: 12 }).withPlainDate('2000-06-01'); // => 2000-06-01T15:24:30

// result contains a non-ISO calendar if present in the input
dt.withCalendar('japanese').withPlainDate('2008-09-06'); // => 2008-09-06T03:24:30[u-ca-japanese]
dt.withPlainDate('2017-09-06[u-ca-japanese]'); // => 2017-09-06T03:24:30[u-ca-japanese]
dt.withCalendar('japanese').withPlainDate('2017-09-06[u-ca-hebrew]'); // => RangeError (calendar conflict)
dt.withCalendar('japanese').withPlainDate('2008-09-06'); // => 2008-09-06T03:24:30[u-ca=japanese]
dt.withPlainDate('2017-09-06[u-ca=japanese]'); // => 2017-09-06T03:24:30[u-ca=japanese]
dt.withCalendar('japanese').withPlainDate('2017-09-06[u-ca=hebrew]'); // => RangeError (calendar conflict)
```

### datetime.**withCalendar**(_calendar_: object | string) : Temporal.PlainDateTime
Expand All @@ -554,7 +554,7 @@ This method is the same as `datetime.with({ calendar })`, but may be more effici
Usage example:

```javascript
dt = Temporal.PlainDateTime.from('1995-12-07T03:24:30.000003500[u-ca-japanese]');
dt = Temporal.PlainDateTime.from('1995-12-07T03:24:30.000003500[u-ca=japanese]');
dt.withCalendar('iso8601'); // => 1995-12-07T03:24:30.000003500
```

Expand Down
8 changes: 4 additions & 4 deletions docs/plainmonthday.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ md = Temporal.PlainMonthDay.from({ month: 2, day: 29, year: 2001 }, { overflow:

// non-ISO calendars
md = Temporal.PlainMonthDay.from({ monthCode: 'M05L', day: 15, calendar: 'hebrew' });
// => 2019-02-20[u-ca-hebrew]
// => 2019-02-20[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, year: 5779, calendar: 'hebrew' });
// => 2019-02-20[u-ca-hebrew]
// => 2019-02-20[u-ca=hebrew]
md = Temporal.PlainMonthDay.from({ month: 6, day: 15, calendar: 'hebrew' });
// => throws (either year or monthCode is required)
md = Temporal.PlainMonthDay.from('2019-02-20[u-ca-hebrew]');
md = Temporal.PlainMonthDay.from('2019-02-20[u-ca=hebrew]');
md.monthCode; // => "M05L"
md.day; // => 15
md.month; // undefined (month property is not present in this type; use monthCode instead)
Expand Down Expand Up @@ -151,7 +151,7 @@ md.monthCode; // => "M08"
md.day; // => 24
md.month; // undefined (no `month` property; use `monthCode` instead)

md = Temporal.PlainMonthDay.from('2019-02-20[u-ca-hebrew]');
md = Temporal.PlainMonthDay.from('2019-02-20[u-ca=hebrew]');
md.monthCode; // => "M05L"
md.day; // => 15
md.month; // undefined (no `month` property; use `monthCode` instead)
Expand Down
4 changes: 2 additions & 2 deletions docs/plainyearmonth.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ym.year; // => 2019
ym.month; // => 6
ym.monthCode; // => "M06"

ym = Temporal.PlainYearMonth.from('2019-02-23[u-ca-hebrew]');
ym = Temporal.PlainYearMonth.from('2019-02-23[u-ca=hebrew]');
ym.year; // => 5779
ym.month; // => 6
ym.monthCode; // => "M05L"
Expand All @@ -202,7 +202,7 @@ As inputs to `from` or `with`, `era` and `eraYear` can be used instead of `year`
Unlike `year`, `eraYear` may decrease as time proceeds because some eras (like the BCE era in the Gregorian calendar) count years backwards.

```javascript
ym = Temporal.PlainYearMonth.from('-000015-01-01[u-ca-gregory]');
ym = Temporal.PlainYearMonth.from('-000015-01-01[u-ca=gregory]');
ym.era;
// => "bce"
ym.eraYear;
Expand Down
20 changes: 10 additions & 10 deletions docs/zoneddatetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Any non-object value is converted to a string, which is expected to be an ISO 86
For example:

```
2020-08-05T20:06:13+09:00[Asia/Tokyo][u-ca-japanese]
2020-08-05T20:06:13+09:00[Asia/Tokyo][u-ca=japanese]
```

If the string isn't valid, then a `RangeError` will be thrown regardless of the value of `overflow`.
Expand Down Expand Up @@ -179,7 +179,7 @@ Example usage:
<!-- prettier-ignore-start -->
```javascript
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30+02:00[Africa/Cairo]');
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca-islamic]');
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30+02:00[Africa/Cairo][u-ca=islamic]');
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30'); // RangeError; time zone ID required
zdt = Temporal.ZonedDateTime.from('1995-12-07T01:24:30Z'); // RangeError; time zone ID required
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30+02:00'); // RangeError; time zone ID required
Expand Down Expand Up @@ -337,7 +337,7 @@ dt.millisecond; // => 0
dt.microsecond; // => 3
dt.nanosecond; // => 500

dt = Temporal.ZonedDateTime.from('2019-02-23T03:24:30.000003500[Europe/Rome][u-ca-hebrew]');
dt = Temporal.ZonedDateTime.from('2019-02-23T03:24:30.000003500[Europe/Rome][u-ca=hebrew]');
dt.year; // => 5779
dt.month; // => 6
dt.monthCode; // => "M05L"
Expand Down Expand Up @@ -466,7 +466,7 @@ As inputs to `from` or `with`, `era` and `eraYear` can be used instead of `year`
Unlike `year`, `eraYear` may decrease as time proceeds because some eras (like the BCE era in the Gregorian calendar) count years backwards.

```javascript
date = Temporal.ZonedDateTime.from('-000015-01-01T12:30[Europe/Rome][u-ca-gregory]');
date = Temporal.ZonedDateTime.from('-000015-01-01T12:30[Europe/Rome][u-ca=gregory]');
date.era;
// => "bce"
date.eraYear;
Expand Down Expand Up @@ -825,9 +825,9 @@ zdt.withPlainDate('2018-09-15'); // => 2018-09-15T03:24:30-07:00[America/Los_Ang
zdt.add({ hours: 12 }).withPlainDate('2000-06-01'); // => 2000-06-01T15:24:30-07:00[America/Los_Angeles]

// result contains a non-ISO calendar if present in the input
zdt.withCalendar('japanese').withPlainDate('2008-09-06'); // => 2008-09-06T03:24:30-07:00[America/Los_Angeles][u-ca-japanese]
zdt.withPlainDate('2017-09-06[u-ca-japanese]'); // => 2017-09-06T03:24:30-07:00[America/Los_Angeles][u-ca-japanese]
zdt.withCalendar('japanese').withPlainDate('2017-09-06[u-ca-hebrew]'); // => RangeError (calendar conflict)
zdt.withCalendar('japanese').withPlainDate('2008-09-06'); // => 2008-09-06T03:24:30-07:00[America/Los_Angeles][u-ca=japanese]
zdt.withPlainDate('2017-09-06[u-ca=japanese]'); // => 2017-09-06T03:24:30-07:00[America/Los_Angeles][u-ca=japanese]
zdt.withCalendar('japanese').withPlainDate('2017-09-06[u-ca=hebrew]'); // => RangeError (calendar conflict)
```

### zonedDateTime.**withTimeZone**(_timeZone_: object | string) : Temporal.ZonedDateTime
Expand Down Expand Up @@ -857,7 +857,7 @@ zdt.withTimeZone('Africa/Accra').toString(); // => "1995-12-06T18:24:30+00:00[Af
Usage example:

```javascript
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca-japanese]');
zdt = Temporal.ZonedDateTime.from('1995-12-07T03:24:30.000003500+09:00[Asia/Tokyo][u-ca=japanese]');
`${zdt.era} ${zdt.year}`; // => "heisei 7"
zdt.withCalendar('iso8601').year; // => 1995
```
Expand Down Expand Up @@ -1246,7 +1246,7 @@ zdt1.equals(zdt1); // => true
Examples:

- `2011-12-03T10:15:30+01:00[Europe/Paris]`
- `2011-12-03T10:15:30+09:00[Asia/Tokyo][u-ca-japanese]`
- `2011-12-03T10:15:30+09:00[Asia/Tokyo][u-ca=japanese]`

This method overrides the `Object.prototype.toString()` method and provides a convenient, unambiguous string representation of `zonedDateTime`.
The string is "round-trippable".
Expand All @@ -1273,7 +1273,7 @@ Example usage:
zdt = Temporal.ZonedDateTime.from({ year: 2019, month: 12, day: 1, hour: 12, timeZone: 'Africa/Lagos' });
zdt.toString(); // => 2019-12-01T12:00+01:00[Africa/Lagos]
zdt.withCalendar('japanese');
zdt.toString(); // => 2019-12-01T12:00+01:00[Africa/Lagos][u-ca-japanese]
zdt.toString(); // => 2019-12-01T12:00+01:00[Africa/Lagos][u-ca=japanese]
```

### zonedDateTime.**toLocaleString**(_locales_?: string | array&lt;string&gt;, _options_?: object) : string
Expand Down
2 changes: 1 addition & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const ES = ObjectAssign({}, ES2020, {
FormatCalendarAnnotation: (id, showCalendar) => {
if (showCalendar === 'never') return '';
if (showCalendar === 'auto' && id === 'iso8601') return '';
return `[u-ca-${id}]`;
return `[u-ca=${id}]`;
},
ParseISODateTime: (isoString, { zoneRequired }) => {
const regex = zoneRequired ? PARSE.instant : PARSE.datetime;
Expand Down
27 changes: 2 additions & 25 deletions polyfill/lib/regex.mjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
// Per specification,
// TZLeadingChar TZChar? TZChar? TZChar? TZChar? TZChar? TZChar? TZChar?
// TZChar? TZChar? TZChar? TZChar? TZChar? TZChar?
// but not one of `.` or `..` or
// CalChar `-` CalChar CalChar `-` CalendarNameComponent
// In plain words, 1 to 14 letters, periods, underscores, or dashes, but not
// starting with a dash, and not consisting only of one or two periods, and not
// of the form (letter)-(2 letters)-(3 or more letters) which conflicts with
// calComponent
const tzComponentNotBCP47 = new RegExp(
[
'\\.\\.[-A-Za-z._]{1,12}',
'\\.[-A-Za-z_][-A-Za-z._]{0,12}',
'_[-A-Za-z._]{0,13}',
'[a-zA-Z](?:[A-Za-z._][-A-Za-z._]{0,12})?',
'[a-zA-Z]-(?:[-._][-A-Za-z._]{0,11})?',
'[a-zA-Z]-[a-zA-Z](?:[-._][-A-Za-z._]{0,10})?',
'[a-zA-Z]-[a-zA-Z][a-zA-Z](?:[A-Za-z._][-A-Za-z._]{0,9})?',
'[a-zA-Z]-[a-zA-Z][a-zA-Z]-(?:[-._][-A-Za-z._]{0,8})?',
'[a-zA-Z]-[a-zA-Z][a-zA-Z]-[a-zA-Z](?:[-._][-A-Za-z._]{0,7})?',
'[a-zA-Z]-[a-zA-Z][a-zA-Z]-[a-zA-Z][a-zA-Z](?:[-._][-A-Za-z._]{0,6})?'
].join('|')
);
const tzComponent = /\.[-A-Za-z_]|\.\.[-A-Za-z._]{1,12}|\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}/;
const offsetNoCapture = /(?:[+\u2212-][0-2][0-9](?::?[0-5][0-9](?::?[0-5][0-9](?:[.,]\d{1,9})?)?)?)/;
export const timeZoneID = new RegExp(
`(?:(?:${tzComponentNotBCP47.source})(?:\\/(?:${tzComponent.source}))*|Etc/GMT[-+]\\d{1,2}|${offsetNoCapture.source})`
`(?:(?:${tzComponent.source})(?:\\/(?:${tzComponent.source}))*|Etc/GMT[-+]\\d{1,2}|${offsetNoCapture.source})`
);

const calComponent = /[A-Za-z0-9]{3,8}/;
Expand All @@ -35,7 +12,7 @@ export const datesplit = new RegExp(`(${yearpart.source})(?:-(\\d{2})-(\\d{2})|(
const timesplit = /(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/;
export const offset = /([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/;
const zonesplit = new RegExp(`(?:([zZ])|(?:${offset.source})?)(?:\\[(${timeZoneID.source})\\])?`);
const calendar = new RegExp(`\\[u-ca-(${calendarID.source})\\]`);
const calendar = new RegExp(`\\[u-ca=(${calendarID.source})\\]`);

export const instant = new RegExp(
`^${datesplit.source}(?:(?:T|\\s+)${timesplit.source})?${zonesplit.source}(?:${calendar.source})?$`,
Expand Down
Loading

0 comments on commit fa38136

Please sign in to comment.