@@ -399,7 +399,24 @@ function fixColorsAndGroups() {
399399 * used to extract hours and minutes from timezone info, e.g '-0900'
400400 * @constant
401401 */
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+ }
403420
404421/**
405422 * 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])$/;
408425 * @param {Number } epoch: seconds since '00:00:00 1970-01-01 UTC'
409426 * @param {String } timezoneInfo: numeric timezone '(+|-)HHMM'
410427 * @returns {String } date in local time in iso-8601 like format
411- *
412- * @globals tzRe
413428 */
414429function formatDateISOLocal ( epoch , timezoneInfo ) {
415- var match = tzRe . exec ( timezoneInfo ) ;
416430 // date corrected by timezone
417431 var localDate = new Date ( 1000 * ( epoch +
418- ( parseInt ( match [ 1 ] , 10 ) * 3600 + parseInt ( match [ 2 ] , 10 ) * 60 ) ) ) ;
432+ timezoneOffset ( timezoneInfo ) ) ) ;
419433 var localDateStr = // e.g. '2005-08-07'
420434 localDate . getUTCFullYear ( ) + '-' +
421435 padLeft ( localDate . getUTCMonth ( ) + 1 , 2 , '0' ) + '-' +
0 commit comments