diff --git a/builtin/apply.c b/builtin/apply.c index 23c18c573b9147b7aaa88a8d1d2f26748e803501..000d3e529722f73321f87084a457d878de037704 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -733,8 +733,8 @@ static int has_epoch_timestamp(const char *nameline) " " "[0-2][0-9]:[0-5][0-9]:00(\\.0+)?" " " - "([-+][0-2][0-9][0-5][0-9])\n"; - const char *timestamp = NULL, *cp; + "([-+][0-2][0-9]:?[0-5][0-9])\n"; + const char *timestamp = NULL, *cp, *colon; static regex_t *stamp; regmatch_t m[10]; int zoneoffset; @@ -764,8 +764,11 @@ static int has_epoch_timestamp(const char *nameline) return 0; } - zoneoffset = strtol(timestamp + m[3].rm_so + 1, NULL, 10); - zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100); + zoneoffset = strtol(timestamp + m[3].rm_so + 1, (char **) &colon, 10); + if (*colon == ':') + zoneoffset = zoneoffset * 60 + strtol(colon + 1, NULL, 10); + else + zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100); if (timestamp[m[3].rm_so] == '-') zoneoffset = -zoneoffset; diff --git a/t/t4132-apply-removal.sh b/t/t4132-apply-removal.sh index bb1ffe3b6cfe491137b34993fe2e3bed99908dff..a2bc1cd37d852a9cab79c946bf88ee9dc958b460 100755 --- a/t/t4132-apply-removal.sh +++ b/t/t4132-apply-removal.sh @@ -30,6 +30,7 @@ test_expect_success setup ' epocWest="1969-12-31 16:00:00.000000000 -0800" && epocGMT="1970-01-01 00:00:00.000000000 +0000" && epocEast="1970-01-01 09:00:00.000000000 +0900" && + epocWest2="1969-12-31 16:00:00 -08:00" && sed -e "s/TS0/$epocWest/" -e "s/TS1/$timeWest/" createWest.patch && sed -e "s/TS0/$epocEast/" -e "s/TS1/$timeEast/" createEast.patch && @@ -46,6 +47,7 @@ test_expect_success setup ' sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest/" removeWest.patch && sed -e "s/TS0/$timeEast/" -e "s/TS1/$epocEast/" removeEast.patch && sed -e "s/TS0/$timeGMT/" -e "s/TS1/$epocGMT/" removeGMT.patch && + sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest2/" removeWest2.patch && echo something >something && >empty