summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorĐoàn Trần Công Danh <congdanhqx@gmail.com>2020-04-24 15:07:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-04-24 21:06:09 (GMT)
commit544ed961a50c3442a3ec5643f2c443cd3e17311a (patch)
tree80a08aecf99b91afd3b838b4185d6de301e23117 /date.c
parentb784840ca84c708708d1ab0b872eb3a6fb3200b5 (diff)
downloadgit-544ed961a50c3442a3ec5643f2c443cd3e17311a.zip
git-544ed961a50c3442a3ec5643f2c443cd3e17311a.tar.gz
git-544ed961a50c3442a3ec5643f2c443cd3e17311a.tar.bz2
date.c: allow compact version of ISO-8601 datetime
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'date.c')
-rw-r--r--date.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/date.c b/date.c
index 2c9071d..f9ea807 100644
--- a/date.c
+++ b/date.c
@@ -687,6 +687,20 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
n++;
} while (isdigit(date[n]));
+ /* 8 digits, compact style of ISO-8601's date: YYYYmmDD */
+ /* 6 digits, compact style of ISO-8601's time: HHMMSS */
+ if (n == 8 || n == 6) {
+ unsigned int num1 = num / 10000;
+ unsigned int num2 = (num % 10000) / 100;
+ unsigned int num3 = num % 100;
+ if (n == 8)
+ set_date(num1, num2, num3, NULL, time(NULL), tm);
+ else if (n == 6 && set_time(num1, num2, num3, tm) == 0 &&
+ *end == '.' && isdigit(end[1]))
+ strtoul(end + 1, &end, 10);
+ return end - date;
+ }
+
/* Four-digit year or a timezone? */
if (n == 4) {
if (num <= 1400 && *offset == -1) {