{"thread":{"id":"26963","subject":"[PATCH (BUGFIX)] gitweb: Fix parsing of negative fractional timezones in JavaScript","startedAt":"2011-04-01T19:06:28Z","lastAt":"2011-04-04T18:30:29Z","messageCount":2,"participants":["Jakub Narebski","J.H."],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"164908","messageId":"20110401190239.9686.12000.stgit@localhost.localdomain","threadId":"26963","inReplyTo":null,"subject":"[PATCH (BUGFIX)] gitweb: Fix parsing of negative fractional timezones in JavaScript","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-04-01T19:06:28Z","receivedAt":"2011-04-01T19:06:28Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Extract converting numerical timezone in the form of '(+|-)HHMM' to\ntimezoneOffset function, and fix parsing of negative fractional\ntimezones.\n\nThis is used to format timestamps in 'blame_incremental' view; this\ncomplements commit 2b1e172 (gitweb: Fix handling of fractional\ntimezones in parse_date, 2011-03-25).\n\nNow\n\n  gitweb.cgi/git.git/blame_incremental/3fe5489:/contrib/gitview/gitview#l853\n\nand\n\n  gitweb.cgi/git.git/blame/3fe5489:/contrib/gitview/gitview#l853\n\nshow the same correct time in author's local timezone in title\n(on mouseover) [Aneesh Kumar K.V, 2006-02-24 00:59:42 +0530].\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis was send earlier as part 3/3 of \n\n  \"[PATCH/RFC 0/3] gitweb: Split gitweb.js, improve JavaScript\"\n  Message-Id: <1301089586-8534-1-git-send-email-jnareb@gmail.com>\n  http://thread.gmane.org/gmane.comp.version-control.git/170021/focus=170024\n\nIt is now send separately as standalone patch, and is not held hostage\nto accepting series that splits gitweb JavaScript file.\n\n gitweb/static/gitweb.js |   24 +++++++++++++++++++-----\n 1 files changed, 19 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/static/gitweb.js b/gitweb/static/gitweb.js\nindex 9c66928..40ec084 100644\n--- a/gitweb/static/gitweb.js\n+++ b/gitweb/static/gitweb.js\n@@ -399,7 +399,24 @@ function fixColorsAndGroups() {\n  * used to extract hours and minutes from timezone info, e.g '-0900'\n  * @constant\n  */\n-var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;\n+var tzRe = /^([+-])([0-9][0-9])([0-9][0-9])$/;\n+\n+/**\n+ * convert numeric timezone +/-ZZZZ to offset from UTC in seconds\n+ *\n+ * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM'\n+ * @returns {Number} offset from UTC in seconds for timezone\n+ *\n+ * @globals tzRe\n+ */\n+function timezoneOffset(timezoneInfo) {\n+\tvar match = tzRe.exec(timezoneInfo);\n+\tvar tz_sign = (match[1] === '-' ? -1 : +1);\n+\tvar tz_hour = parseInt(match[2],10);\n+\tvar tz_min  = parseInt(match[3],10);\n+\n+\treturn tz_sign*(((tz_hour*60) + tz_min)*60);\n+}\n \n /**\n  * return date in local time formatted in iso-8601 like format\n@@ -408,14 +425,11 @@ var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;\n  * @param {Number} epoch: seconds since '00:00:00 1970-01-01 UTC'\n  * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM'\n  * @returns {String} date in local time in iso-8601 like format\n- *\n- * @globals tzRe\n  */\n function formatDateISOLocal(epoch, timezoneInfo) {\n-\tvar match = tzRe.exec(timezoneInfo);\n \t// date corrected by timezone\n \tvar localDate = new Date(1000 * (epoch +\n-\t\t(parseInt(match[1],10)*3600 + parseInt(match[2],10)*60)));\n+\t\ttimezoneOffset(timezoneInfo)));\n \tvar localDateStr = // e.g. '2005-08-07'\n \t\tlocalDate.getUTCFullYear()                 + '-' +\n \t\tpadLeft(localDate.getUTCMonth()+1, 2, '0') + '-' +\n"},{"id":"165131","messageId":"4D9A0E45.6060101@eaglescrag.net","threadId":"26963","inReplyTo":"20110401190239.9686.12000.stgit@localhost.localdomain","subject":"Re: [PATCH (BUGFIX)] gitweb: Fix parsing of negative fractional timezones in JavaScript","fromName":"J.H.","fromEmail":"warthog9@eaglescrag.net","sentAt":"2011-04-04T18:30:29Z","receivedAt":"2011-04-04T18:30:29Z","isPatch":true,"sender":{"key":"warthog9@kernel.org","avatar":"https://avatars.githubusercontent.com/u/2334704?v=4"},"body":"Looks fine to me.\n\n- John 'Warthog9' Hawley\n\nOn 04/01/2011 12:06 PM, Jakub Narebski wrote:\n> Extract converting numerical timezone in the form of '(+|-)HHMM' to\n> timezoneOffset function, and fix parsing of negative fractional\n> timezones.\n> \n> This is used to format timestamps in 'blame_incremental' view; this\n> complements commit 2b1e172 (gitweb: Fix handling of fractional\n> timezones in parse_date, 2011-03-25).\n> \n> Now\n> \n>   gitweb.cgi/git.git/blame_incremental/3fe5489:/contrib/gitview/gitview#l853\n> \n> and\n> \n>   gitweb.cgi/git.git/blame/3fe5489:/contrib/gitview/gitview#l853\n> \n> show the same correct time in author's local timezone in title\n> (on mouseover) [Aneesh Kumar K.V, 2006-02-24 00:59:42 +0530].\n> \n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> ---\n> This was send earlier as part 3/3 of \n> \n>   \"[PATCH/RFC 0/3] gitweb: Split gitweb.js, improve JavaScript\"\n>   Message-Id: <1301089586-8534-1-git-send-email-jnareb@gmail.com>\n>   http://thread.gmane.org/gmane.comp.version-control.git/170021/focus=170024\n> \n> It is now send separately as standalone patch, and is not held hostage\n> to accepting series that splits gitweb JavaScript file.\n> \n>  gitweb/static/gitweb.js |   24 +++++++++++++++++++-----\n>  1 files changed, 19 insertions(+), 5 deletions(-)\n> \n> diff --git a/gitweb/static/gitweb.js b/gitweb/static/gitweb.js\n> index 9c66928..40ec084 100644\n> --- a/gitweb/static/gitweb.js\n> +++ b/gitweb/static/gitweb.js\n> @@ -399,7 +399,24 @@ function fixColorsAndGroups() {\n>   * used to extract hours and minutes from timezone info, e.g '-0900'\n>   * @constant\n>   */\n> -var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;\n> +var tzRe = /^([+-])([0-9][0-9])([0-9][0-9])$/;\n> +\n> +/**\n> + * convert numeric timezone +/-ZZZZ to offset from UTC in seconds\n> + *\n> + * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM'\n> + * @returns {Number} offset from UTC in seconds for timezone\n> + *\n> + * @globals tzRe\n> + */\n> +function timezoneOffset(timezoneInfo) {\n> +\tvar match = tzRe.exec(timezoneInfo);\n> +\tvar tz_sign = (match[1] === '-' ? -1 : +1);\n> +\tvar tz_hour = parseInt(match[2],10);\n> +\tvar tz_min  = parseInt(match[3],10);\n> +\n> +\treturn tz_sign*(((tz_hour*60) + tz_min)*60);\n> +}\n>  \n>  /**\n>   * return date in local time formatted in iso-8601 like format\n> @@ -408,14 +425,11 @@ var tzRe = /^([+-][0-9][0-9])([0-9][0-9])$/;\n>   * @param {Number} epoch: seconds since '00:00:00 1970-01-01 UTC'\n>   * @param {String} timezoneInfo: numeric timezone '(+|-)HHMM'\n>   * @returns {String} date in local time in iso-8601 like format\n> - *\n> - * @globals tzRe\n>   */\n>  function formatDateISOLocal(epoch, timezoneInfo) {\n> -\tvar match = tzRe.exec(timezoneInfo);\n>  \t// date corrected by timezone\n>  \tvar localDate = new Date(1000 * (epoch +\n> -\t\t(parseInt(match[1],10)*3600 + parseInt(match[2],10)*60)));\n> +\t\ttimezoneOffset(timezoneInfo)));\n>  \tvar localDateStr = // e.g. '2005-08-07'\n>  \t\tlocalDate.getUTCFullYear()                 + '-' +\n>  \t\tpadLeft(localDate.getUTCMonth()+1, 2, '0') + '-' +\n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}