Skip to content

Commit

Permalink
Normative: Add optional calendar to PlainTime, PlainYearMonth, and Pl…
Browse files Browse the repository at this point in the history
…ainMonthDay productions

This was mistakenly left out when we added calendar annotations to
Temporal.

Note that PlainTime currently only supports the iso8601 calendar and
Temporal.PlainTime.from() will throw if any other calendar is specified in
the calendar annotation. This keeps open the possibility to support more
calendars in PlainTime in a future proposal.

Note also that only the YYYY-MM-DD forms of PlainMonthDay and
PlainYearMonth support calendar annotations. The YYYY-MM and MM-DD forms
always require the iso8601 calendar, because otherwise there is no
reference ISO year or reference ISO day, respectively.

Closes: #1896
Closes: #1912
  • Loading branch information
ptomato committed Dec 17, 2021
1 parent bdf60f5 commit 7e58ba3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions polyfill/test/validStrings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ const timeSpecSeparator = seq(dateTimeSeparator, timeSpec);
const dateSpecMonthDay = seq(['--'], dateMonth, ['-'], dateDay);
const dateSpecYearMonth = seq(dateYear, ['-'], dateMonth);
const date = choice(seq(dateYear, '-', dateMonth, '-', dateDay), seq(dateYear, dateMonth, dateDay));
const time = seq(timeSpec, [timeZone]);
const dateTime = seq(date, [timeSpecSeparator], [timeZone]);
const calendarDateTime = seq(dateTime, [calendar]);
const calendarTime = seq(timeSpec, [timeZone], [calendar]);

const durationFractionalPart = withCode(between(1, 9, digit()), (data, result) => {
const fraction = result.padEnd(9, '0');
Expand Down Expand Up @@ -353,10 +353,10 @@ const goals = {
Date: calendarDateTime,
DateTime: calendarDateTime,
Duration: duration,
MonthDay: choice(dateSpecMonthDay, dateTime),
Time: choice(time, dateTime),
MonthDay: choice(dateSpecMonthDay, calendarDateTime),
Time: choice(calendarTime, calendarDateTime),
TimeZone: choice(temporalTimeZoneIdentifier, seq(date, [timeSpecSeparator], timeZone, [calendar])),
YearMonth: choice(dateSpecYearMonth, dateTime),
YearMonth: choice(dateSpecYearMonth, calendarDateTime),
ZonedDateTime: zonedDateTime
};

Expand All @@ -378,10 +378,10 @@ const comparisonItems = {
'microseconds',
'nanoseconds'
],
MonthDay: ['month', 'day'],
Time: timeItems,
MonthDay: ['month', 'day', 'calendar'],
Time: [...timeItems, 'calendar'],
TimeZone: ['offset', 'ianaName'],
YearMonth: ['year', 'month'],
YearMonth: ['year', 'month', 'calendar'],
ZonedDateTime: [...dateItems, ...timeItems, 'offset', 'ianaName', 'calendar']
};
const plainModes = ['Date', 'DateTime', 'MonthDay', 'Time', 'YearMonth'];
Expand Down
16 changes: 8 additions & 8 deletions spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -930,15 +930,15 @@ <h1>ISO 8601 grammar</h1>
TimeHour `:` TimeMinute `:` TimeSecond TimeFraction?
TimeHour TimeMinute TimeSecond TimeFraction?

Time :
TimeSpec TimeZone?

TimeSpecSeparator :
DateTimeSeparator TimeSpec

DateTime :
Date TimeSpecSeparator? TimeZone?

CalendarTime :
TimeSpec TimeZone? Calendar?

CalendarDateTime:
DateTime Calendar?

Expand Down Expand Up @@ -1026,11 +1026,11 @@ <h1>ISO 8601 grammar</h1>

TemporalMonthDayString :
DateSpecMonthDay
DateTime
CalendarDateTime

TemporalTimeString :
Time
DateTime
CalendarTime
CalendarDateTime

TemporalTimeZoneIdentifier :
TimeZoneNumericUTCOffset
Expand All @@ -1042,7 +1042,7 @@ <h1>ISO 8601 grammar</h1>

TemporalYearMonthString :
DateSpecYearMonth
DateTime
CalendarDateTime

TemporalZonedDateTimeString :
Date TimeSpecSeparator? TimeZoneNameRequired Calendar?
Expand All @@ -1051,7 +1051,7 @@ <h1>ISO 8601 grammar</h1>
CalendarName
TemporalInstantString
CalendarDateTime
Time
CalendarTime
DateSpecYearMonth
DateSpecMonthDay

Expand Down

0 comments on commit 7e58ba3

Please sign in to comment.