Skip to content

Commit 163d86b

Browse files
committed
[WIP] Optional hour:minute, second and timezone in TimeValue
1 parent 5f8ad46 commit 163d86b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/values/TimeValue.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( iso8601
2828
this._time = {};
2929

3030
try {
31-
var matches = /^([+-]?\d+)-(\d+)-(\d+)T(\d{2}):(\d{2}):(\d{2})Z$/.exec( iso8601 );
31+
var matches = /^([+-]?\d+)-(\d+)-(\d+)T(?:(\d+):(\d+)(?::(\d+))Z?)$/.exec( iso8601 );
3232
this._time.year = parseInt( matches[1], 10 );
3333
this._time.month = parseInt( matches[2], 10 );
3434
this._time.day = parseInt( matches[3], 10 );
35-
this._time.hour = parseInt( matches[4], 10 );
36-
this._time.minute = parseInt( matches[5], 10 );
37-
this._time.second = parseInt( matches[6], 10 );
35+
this._time.hour = parseInt( matches[4] || 0, 10 );
36+
this._time.minute = parseInt( matches[5] || 0, 10 );
37+
this._time.second = parseInt( matches[6] || 0, 10 );
3838
} catch( e ) {
3939
throw new Error( 'Unable to process supposed ISO8601 string' );
4040
}

0 commit comments

Comments
 (0)