Skip to content

Commit fa38cfc

Browse files
committed
Merge branch 'maint'
* maint: Documentation: trivial grammar fix in core.worktree description gitweb: Fix parsing of negative fractional timezones in JavaScript
2 parents 2071fb0 + d424a47 commit fa38cfc

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Documentation/config.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ core.worktree::
320320
Set the path to the root of the working tree.
321321
This can be overridden by the GIT_WORK_TREE environment
322322
variable and the '--work-tree' command line option.
323-
The value can an absolute path or relative to the path to
323+
The value can be an absolute path or relative to the path to
324324
the .git directory, which is either specified by --git-dir
325325
or GIT_DIR, or automatically discovered.
326326
If --git-dir or GIT_DIR is specified but none of

gitweb/static/gitweb.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
414429
function 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

Comments
 (0)