@@ -399,7 +399,24 @@ function fixColorsAndGroups() {
399
399
* used to extract hours and minutes from timezone info, e.g '-0900'
400
400
* @constant
401
401
*/
402
- var tzRe = / ^ ( [ + - ] [ 0 - 9 ] [ 0 - 9 ] ) ( [ 0 - 9 ] [ 0 - 9 ] ) $ / ;
402
+ var tzRe = / ^ ( [ + - ] ) ( [ 0 - 9 ] [ 0 - 9 ] ) ( [ 0 - 9 ] [ 0 - 9 ] ) $ / ;
403
+
404
+ /**
405
+ * convert numeric timezone +/-ZZZZ to offset from UTC in seconds
406
+ *
407
+ * @param {String } timezoneInfo: numeric timezone '(+|-)HHMM'
408
+ * @returns {Number } offset from UTC in seconds for timezone
409
+ *
410
+ * @globals tzRe
411
+ */
412
+ function timezoneOffset ( timezoneInfo ) {
413
+ var match = tzRe . exec ( timezoneInfo ) ;
414
+ var tz_sign = ( match [ 1 ] === '-' ? - 1 : + 1 ) ;
415
+ var tz_hour = parseInt ( match [ 2 ] , 10 ) ;
416
+ var tz_min = parseInt ( match [ 3 ] , 10 ) ;
417
+
418
+ return tz_sign * ( ( ( tz_hour * 60 ) + tz_min ) * 60 ) ;
419
+ }
403
420
404
421
/**
405
422
* return date in local time formatted in iso-8601 like format
@@ -408,14 +425,11 @@ var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;
408
425
* @param {Number } epoch: seconds since '00:00:00 1970-01-01 UTC'
409
426
* @param {String } timezoneInfo: numeric timezone '(+|-)HHMM'
410
427
* @returns {String } date in local time in iso-8601 like format
411
- *
412
- * @globals tzRe
413
428
*/
414
429
function formatDateISOLocal ( epoch , timezoneInfo ) {
415
- var match = tzRe . exec ( timezoneInfo ) ;
416
430
// date corrected by timezone
417
431
var localDate = new Date ( 1000 * ( epoch +
418
- ( parseInt ( match [ 1 ] , 10 ) * 3600 + parseInt ( match [ 2 ] , 10 ) * 60 ) ) ) ;
432
+ timezoneOffset ( timezoneInfo ) ) ) ;
419
433
var localDateStr = // e.g. '2005-08-07'
420
434
localDate . getUTCFullYear ( ) + '-' +
421
435
padLeft ( localDate . getUTCMonth ( ) + 1 , 2 , '0' ) + '-' +
0 commit comments