@@ -270,33 +270,13 @@ const timeZoneUTCOffsetSign = withCode(
270
270
sign ,
271
271
( data , result ) => ( data . offsetSign = result === '-' || result === '\u2212' ? '-' : '+' )
272
272
) ;
273
- function saveOffsetHour ( data , result ) {
274
- data . offsetHour = + result ;
275
- }
276
- const timeZoneUTCOffsetHour = withCode ( hour , saveOffsetHour ) ;
277
- const timeZoneUTCOffsetHourNotValidMonth = withCode ( zeroPaddedInclusive ( 13 , 23 , 2 ) , saveOffsetHour ) ;
278
- const timeZoneUTCOffsetMinute = withCode ( minuteSecond , ( data , result ) => ( data . offsetMinute = + result ) ) ;
279
- const timeZoneUTCOffsetSecond = withCode ( minuteSecond , ( data , result ) => ( data . offsetSecond = + result ) ) ;
280
- const timeZoneUTCOffsetFraction = withCode ( fraction , ( data , result ) => {
281
- result = result . slice ( 1 ) ;
282
- const fraction = result . padEnd ( 9 , '0' ) ;
283
- data . offsetFraction = + fraction ;
284
- } ) ;
285
- function saveOffset ( data ) {
286
- if ( data . offsetSign !== undefined && data . offsetHour !== undefined ) {
287
- const h = `${ data . offsetHour } ` . padStart ( 2 , '0' ) ;
288
- const m = `${ data . offsetMinute || 0 } ` . padStart ( 2 , '0' ) ;
289
- const s = `${ data . offsetSecond || 0 } ` . padStart ( 2 , '0' ) ;
290
- data . offset = `${ data . offsetSign } ${ h } :${ m } ` ;
291
- if ( data . offsetFraction ) {
292
- let fraction = `${ data . offsetFraction } ` . padStart ( 9 , '0' ) ;
293
- while ( fraction . endsWith ( '0' ) ) fraction = fraction . slice ( 0 , - 1 ) ;
294
- data . offset += `:${ s } .${ fraction } ` ;
295
- } else if ( data . offsetSecond ) {
296
- data . offset += `:${ s } ` ;
297
- }
298
- if ( data . offset === '-00:00' ) data . offset = '+00:00' ;
299
- }
273
+ const timeZoneUTCOffsetHour = hour ;
274
+ const timeZoneUTCOffsetHourNotValidMonth = zeroPaddedInclusive ( 13 , 23 , 2 ) ;
275
+ const timeZoneUTCOffsetMinute = minuteSecond ;
276
+ const timeZoneUTCOffsetSecond = minuteSecond ;
277
+ const timeZoneUTCOffsetFraction = fraction ;
278
+ function saveOffset ( data , result ) {
279
+ data . offset = ES . GetCanonicalTimeZoneIdentifier ( result ) . toString ( ) ;
300
280
}
301
281
const timeZoneNumericUTCOffset = withCode (
302
282
seq (
@@ -333,25 +313,19 @@ const timeZoneUTCOffsetName = seq(
333
313
hour ,
334
314
choice ( [ minuteSecond , [ minuteSecond , [ fraction ] ] ] , seq ( ':' , minuteSecond , [ ':' , minuteSecond , [ fraction ] ] ) )
335
315
) ;
336
- const timeZoneBracketedName = withCode (
337
- choice ( timeZoneUTCOffsetName , ...timezoneNames ) ,
338
- ( data , result ) => ( data . ianaName = ES . GetCanonicalTimeZoneIdentifier ( result ) . toString ( ) )
339
- ) ;
340
- const timeZoneBracketedAnnotation = seq ( '[' , timeZoneBracketedName , ']' ) ;
341
- const timeZoneIANAName = withCode (
342
- choice ( ...timezoneNames ) ,
316
+ const timeZoneIANAName = choice ( ...timezoneNames ) ;
317
+ const timeZoneIdentifier = withCode (
318
+ choice ( timeZoneUTCOffsetName , timeZoneIANAName ) ,
343
319
( data , result ) => ( data . ianaName = ES . GetCanonicalTimeZoneIdentifier ( result ) . toString ( ) )
344
320
) ;
321
+ const timeZoneBracketedAnnotation = seq ( '[' , timeZoneIdentifier , ']' ) ;
345
322
const timeZoneOffsetRequired = withCode ( seq ( timeZoneUTCOffset , [ timeZoneBracketedAnnotation ] ) , ( data ) => {
346
323
if ( ! ( 'offset' in data ) ) data . offset = undefined ;
347
324
} ) ;
348
325
const timeZoneNameRequired = withCode ( seq ( [ timeZoneUTCOffset ] , timeZoneBracketedAnnotation ) , ( data ) => {
349
326
if ( ! ( 'offset' in data ) ) data . offset = undefined ;
350
327
} ) ;
351
328
const timeZone = choice ( timeZoneOffsetRequired , timeZoneNameRequired ) ;
352
- const temporalTimeZoneIdentifier = withCode ( choice ( timeZoneNumericUTCOffset , timeZoneIANAName ) , ( data ) => {
353
- if ( ! ( 'offset' in data ) ) data . offset = undefined ;
354
- } ) ;
355
329
const calendarName = withCode ( choice ( ...calendarNames ) , ( data , result ) => ( data . calendar = result ) ) ;
356
330
const calendar = seq ( '[u-ca=' , calendarName , ']' ) ;
357
331
const timeSpec = seq (
@@ -464,7 +438,7 @@ const goals = {
464
438
Duration : duration ,
465
439
MonthDay : choice ( dateSpecMonthDay , calendarDateTime ) ,
466
440
Time : choice ( calendarTime , calendarDateTimeTimeRequired ) ,
467
- TimeZone : choice ( temporalTimeZoneIdentifier , seq ( date , [ timeSpecSeparator ] , timeZone , [ calendar ] ) ) ,
441
+ TimeZone : choice ( timeZoneIdentifier , seq ( date , [ timeSpecSeparator ] , timeZone , [ calendar ] ) ) ,
468
442
YearMonth : choice ( dateSpecYearMonth , calendarDateTime ) ,
469
443
ZonedDateTime : zonedDateTime
470
444
} ;
0 commit comments