@@ -227,13 +227,6 @@ function saveSecond(data, result) {
227
227
const timeHour = withCode ( hour , saveHour ) ;
228
228
const timeMinute = withCode ( minuteSecond , saveMinute ) ;
229
229
const timeSecond = withCode ( choice ( minuteSecond , '60' ) , saveSecond ) ;
230
- const timeHourNotValidMonth = withCode ( choice ( '00' , zeroPaddedInclusive ( 13 , 23 , 2 ) ) , saveHour ) ;
231
- const timeHourNot31DayMonth = withCode ( choice ( '02' , '04' , '06' , '09' , '11' ) , saveHour ) ;
232
- const timeHour2Only = withCode ( '02' , saveHour ) ;
233
- const timeMinuteNotValidDay = withCode ( choice ( '00' , zeroPaddedInclusive ( 32 , 59 , 2 ) ) , saveMinute ) ;
234
- const timeMinute30Only = withCode ( '30' , saveMinute ) ;
235
- const timeMinute31Only = withCode ( '31' , saveMinute ) ;
236
- const timeSecondNotValidMonth = withCode ( choice ( '00' , zeroPaddedInclusive ( 13 , 60 , 2 ) ) , saveSecond ) ;
237
230
const timeFraction = withCode ( fraction , ( data , result ) => {
238
231
result = result . slice ( 1 ) ;
239
232
const fraction = result . padEnd ( 9 , '0' ) ;
@@ -246,7 +239,6 @@ const timeZoneUTCOffsetSign = withCode(
246
239
( data , result ) => ( data . offsetSign = result === '-' || result === '\u2212' ? '-' : '+' )
247
240
) ;
248
241
const timeZoneUTCOffsetHour = hour ;
249
- const timeZoneUTCOffsetHourNotValidMonth = zeroPaddedInclusive ( 13 , 23 , 2 ) ;
250
242
const timeZoneUTCOffsetMinute = minuteSecond ;
251
243
const timeZoneUTCOffsetSecond = minuteSecond ;
252
244
const timeZoneUTCOffsetFraction = fraction ;
@@ -264,24 +256,6 @@ const timeZoneNumericUTCOffset = withCode(
264
256
) ,
265
257
saveOffset
266
258
) ;
267
- const timeZoneNumericUTCOffsetNotAmbiguous = withCode (
268
- choice (
269
- seq ( character ( '+\u2212' ) , timeZoneUTCOffsetHour ) ,
270
- seq (
271
- timeZoneUTCOffsetSign ,
272
- timeZoneUTCOffsetHour ,
273
- choice (
274
- seq ( timeZoneUTCOffsetMinute , [ timeZoneUTCOffsetSecond , [ timeZoneUTCOffsetFraction ] ] ) ,
275
- seq ( ':' , timeZoneUTCOffsetMinute , [ ':' , timeZoneUTCOffsetSecond , [ timeZoneUTCOffsetFraction ] ] )
276
- )
277
- )
278
- ) ,
279
- saveOffset
280
- ) ;
281
- const timeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour = withCode (
282
- choice ( timeZoneNumericUTCOffsetNotAmbiguous , seq ( '-' , timeZoneUTCOffsetHourNotValidMonth ) ) ,
283
- saveOffset
284
- ) ;
285
259
const timeZoneUTCOffset = choice ( utcDesignator , timeZoneNumericUTCOffset ) ;
286
260
const timeZoneUTCOffsetName = seq (
287
261
sign ,
@@ -307,29 +281,14 @@ const timeSpec = seq(
307
281
timeHour ,
308
282
choice ( [ ':' , timeMinute , [ ':' , timeSecond , [ timeFraction ] ] ] , seq ( timeMinute , [ timeSecond , [ timeFraction ] ] ) )
309
283
) ;
310
- const timeSpecWithOptionalTimeZoneNotAmbiguous = choice (
311
- seq ( timeHour , [ timeZoneNumericUTCOffsetNotAmbiguous ] , [ timeZoneBracketedAnnotation ] ) ,
312
- seq ( timeHourNotValidMonth , timeZone ) ,
313
- seq (
314
- choice (
315
- seq ( timeHourNotValidMonth , timeMinute ) ,
316
- seq ( timeHour , timeMinuteNotValidDay ) ,
317
- seq ( timeHourNot31DayMonth , timeMinute31Only ) ,
318
- seq ( timeHour2Only , timeMinute30Only )
319
- ) ,
320
- [ timeZoneBracketedAnnotation ]
321
- ) ,
322
- seq (
323
- timeHour ,
324
- timeMinute ,
325
- choice (
326
- seq ( timeZoneNumericUTCOffsetNotAmbiguousAllowedNegativeHour , [ timeZoneBracketedAnnotation ] ) ,
327
- seq ( timeSecondNotValidMonth , [ timeZone ] ) ,
328
- seq ( timeSecond , timeFraction , [ timeZone ] )
329
- )
330
- ) ,
331
- seq ( timeHour , ':' , timeMinute , [ ':' , timeSecond , [ timeFraction ] ] , [ timeZone ] )
332
- ) ;
284
+ const timeSpecWithOptionalTimeZoneNotAmbiguous = withSyntaxConstraints ( seq ( timeSpec , [ timeZone ] ) , ( result ) => {
285
+ if ( / ^ (?: (? ! 0 2 - ? 3 0 ) (?: 0 [ 1 - 9 ] | 1 [ 0 1 2 ] ) - ? (?: 0 [ 1 - 9 ] | [ 1 2 ] [ 0 - 9 ] | 3 0 ) | (?: 0 [ 1 3 5 7 8 ] | 1 0 | 1 2 ) - ? 3 1 ) $ / . test ( result ) ) {
286
+ throw new SyntaxError ( 'valid PlainMonthDay' ) ;
287
+ }
288
+ if ( / ^ (? ! [ − - ] 0 0 0 0 0 0 ) (?: [ 0 - 9 ] { 4 } | [ + − - ] [ 0 - 9 ] { 6 } ) - ? (?: 0 [ 1 - 9 ] | 1 [ 0 1 2 ] ) $ / . test ( result ) ) {
289
+ throw new SyntaxError ( 'valid PlainYearMonth' ) ;
290
+ }
291
+ } ) ;
333
292
const timeSpecSeparator = seq ( dateTimeSeparator , timeSpec ) ;
334
293
335
294
function validateDayOfMonth ( result , { year, month, day } ) {
0 commit comments