File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const match1to2 = /\d\d?/ // 0 - 99
88const matchUpperAMPM = / [ A P ] M /
99const matchLowerAMPM = / [ a p ] m /
1010const matchSigned = / [ + - ] ? \d + / // -inf - inf
11- const matchOffset = / [ + - ] \d \d : ? \d \d / // +00:00 -00:00 +0000 or -0000
11+ const matchOffset = / ( [ + - ] \d \d : ? \d \d | Z ) / // +00:00 -00:00 +0000, -0000 or Z
1212const matchAbbreviation = / [ A - Z ] { 3 , 4 } / // CET
1313
1414const parseTokenExpressions = { }
@@ -92,6 +92,10 @@ function addParseToken (tokens, property) {
9292}
9393
9494function offsetFromString ( string ) {
95+ if ( string === 'Z' ) {
96+ return 0
97+ }
98+
9599 const parts = string . match ( / ( [ + - ] | \d \d ) / g)
96100 const minutes = + ( parts [ 1 ] * 60 ) + + parts [ 2 ]
97101 return minutes === 0 ? 0 : parts [ 0 ] === '+' ? - minutes : minutes
Original file line number Diff line number Diff line change @@ -72,12 +72,18 @@ it('recognizes noon', () => {
7272
7373it ( 'format parser caching code works' , ( ) => {
7474 parseZonedTime ( '2018' , 'YYYY' )
75- const time = parseZonedTime ( '2018' , 'YYYY' )
7675 expect ( typeof time === 'object' ) . toBeTruthy ( )
7776 const { year } = time
7877 expect ( year ) . toEqual ( 2018 )
7978} )
8079
80+ it ( 'recognizes ISO UTC timezone' , ( ) => {
81+ const time = parseZonedTime ( 'Z' , 'Z' )
82+ const { zone } = time
83+
84+ expect ( zone . offset ) . toEqual ( 0 )
85+ } )
86+
8187it ( 'leaves non-token parts of the format intact' , ( ) => {
8288 const time = parseZonedTime ( ' S:/-.() SS h ' , ' [S]:/-.()[ SS h ]' )
8389 expect ( typeof time === 'object' ) . toBeTruthy ( )
You can’t perform that action at this time.
0 commit comments