{"thread":{"id":"23846","subject":"[PATCHv2] Accept the timezone specifiers [+-]hh:mm and [+-]hh in addition to [+-]hhmm","startedAt":"2010-05-19T20:49:36Z","lastAt":"2010-05-19T20:49:37Z","messageCount":2,"participants":["Marcus Comstedt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"141925","messageId":"1274302177-3573-1-git-send-email-marcus@mc.pp.se","threadId":"23846","inReplyTo":null,"subject":"[PATCHv2] Accept the timezone specifiers [+-]hh:mm and [+-]hh in addition to [+-]hhmm","fromName":"Marcus Comstedt","fromEmail":"marcus@mc.pp.se","sentAt":"2010-05-19T20:49:36Z","receivedAt":"2010-05-19T20:49:36Z","isPatch":false,"sender":{"key":"marcus@mc.pp.se","avatar":"https://avatars.githubusercontent.com/u/411296?v=4"},"body":"Ok, here's a new attempt for the +hh(:mm) timezones, which should be\nsemantically equivalent to the previous one.  In particular, I tested\nthe following corner cases:\n\n  check_parse '+31/05/06 1980 01:02:03' '1980-05-06 01:02:03 +0000'\n  check_parse '+1979/05/06/03 01:02:03' '2003-05-06 01:02:03 +0000'\n  check_parse '+11:5:6 1999/04/01' '1999-03-31 18:06:00 +0000'\n  check_parse '+11:73 Jun 15 10:00:00' bad\n\nI'm not arguing that these results are \"correct\" or anything, I just\nobserve that it was like that before, and so by conservatively not\nchanging them, I shouldn't break anything...\n\n(Ok, the last one _is_ a change from how it was in the before time,\n in the long long ago, but it's the same as it was with the last\n version of the patch.)\n\n\n  // Marcus\n"},{"id":"141926","messageId":"1274302177-3573-2-git-send-email-marcus@mc.pp.se","threadId":"23846","inReplyTo":"1274302177-3573-1-git-send-email-marcus@mc.pp.se","subject":"[PATCH] Accept the timezone specifiers [+-]hh:mm and [+-]hh in addition to [+-]hhmm","fromName":"Marcus Comstedt","fromEmail":"marcus@mc.pp.se","sentAt":"2010-05-19T20:49:37Z","receivedAt":"2010-05-19T20:49:37Z","isPatch":true,"sender":{"key":"marcus@mc.pp.se","avatar":"https://avatars.githubusercontent.com/u/411296?v=4"},"body":"ISO 8601 specifies three syntaxes for timezones other than \"Z\".\ngit already supports the +-hhmm syntax.  This patch adds support\nfor the other two: +-hh:mm and +-hh.\n\nSigned-off-by: Marcus Comstedt <marcus@mc.pp.se>\n---\n date.c |   39 ++++++++++++++++++++++++++-------------\n 1 files changed, 26 insertions(+), 13 deletions(-)\n\ndiff --git a/date.c b/date.c\nindex 6bae49c..f2cad1f 100644\n--- a/date.c\n+++ b/date.c\n@@ -555,21 +555,34 @@ static int match_tz(const char *date, int *offp)\n \tint min, hour;\n \tint n = end - date - 1;\n \n-\tmin = offset % 100;\n-\thour = offset / 100;\n+\tif (n == 2 && offset <= 14) {\n+\t\t/* +HH:MM (ISO 8601) or +HH (ISO 8601 abbreviated) */\n+\t\thour = offset;\n+\t\tif (date[3] == ':') {\n+\t\t\tmin = strtoul(date + 4, &end, 10);\n+\t\t\tif (end != date + 6) {\n+\t\t\t\t/* there was no minute field, but we're\n+\t\t\t\t   fine with just the hour */\n+\t\t\t\tend = (char *)date + 3;\n+\t\t\t\tmin = 0;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tmin = 0;\n+\t\t}\n+\t} else if (n < 3) {\n+\t\treturn end - date; /* we want at least 3 digits */\n+\t} else {\n+\t\tmin = offset % 100;\n+\t\thour = offset / 100;\n+\t}\n \n-\t/*\n-\t * Don't accept any random crap.. At least 3 digits, and\n-\t * a valid minute. We might want to check that the minutes\n-\t * are divisible by 30 or something too.\n-\t */\n-\tif (min < 60 && n > 2) {\n-\t\toffset = hour*60+min;\n-\t\tif (*date == '-')\n-\t\t\toffset = -offset;\n+\tif (60 <= min)\n+\t\treturn end - date; /* invalid minute */\n \n-\t\t*offp = offset;\n-\t}\n+\toffset = hour * 60 + min;\n+\tif (*date == '-')\n+\t\toffset = -offset;\n+\t*offp = offset;\n \treturn end - date;\n }\n \n-- \n1.7.0.4\n"}]}