X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gitweb%2Fstatic%2Fgitweb.js;h=40ec08440b047718bece8efa469683e4b768b68d;hb=11c3e2b7bd617334e7730950166188e94e003f2b;hp=9c66928c4af8cf37b9c13a6a40936523e16fcc6f;hpb=d25c72f7da5116f7b7a1f88a59d2bc14415a03b2;p=git.git diff --git a/gitweb/static/gitweb.js b/gitweb/static/gitweb.js index 9c66928c4..40ec08440 100644 --- a/gitweb/static/gitweb.js +++ b/gitweb/static/gitweb.js @@ -399,7 +399,24 @@ function fixColorsAndGroups() { * used to extract hours and minutes from timezone info, e.g '-0900' * @constant */ -var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/; +var tzRe = /^([+-])([0-9][0-9])([0-9][0-9])$/; + +/** + * convert numeric timezone +/-ZZZZ to offset from UTC in seconds + * + * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM' + * @returns {Number} offset from UTC in seconds for timezone + * + * @globals tzRe + */ +function timezoneOffset(timezoneInfo) { + var match = tzRe.exec(timezoneInfo); + var tz_sign = (match[1] === '-' ? -1 : +1); + var tz_hour = parseInt(match[2],10); + var tz_min = parseInt(match[3],10); + + return tz_sign*(((tz_hour*60) + tz_min)*60); +} /** * 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])$/; * @param {Number} epoch: seconds since '00:00:00 1970-01-01 UTC' * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM' * @returns {String} date in local time in iso-8601 like format - * - * @globals tzRe */ function formatDateISOLocal(epoch, timezoneInfo) { - var match = tzRe.exec(timezoneInfo); // date corrected by timezone var localDate = new Date(1000 * (epoch + - (parseInt(match[1],10)*3600 + parseInt(match[2],10)*60))); + timezoneOffset(timezoneInfo))); var localDateStr = // e.g. '2005-08-07' localDate.getUTCFullYear() + '-' + padLeft(localDate.getUTCMonth()+1, 2, '0') + '-' +