From 7999563138e102e5b2e7f3f6a0a726e683ae5169 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 8 Nov 2019 10:42:03 +0100 Subject: [PATCH] lib/timeutils: add %Y-%m-%dT%H:%M:%S to parse_timestamp() Signed-off-by: Karel Zak --- lib/timeutils.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/timeutils.c b/lib/timeutils.c index d403ced9031..96485045bef 100644 --- a/lib/timeutils.c +++ b/lib/timeutils.c @@ -179,6 +179,7 @@ int parse_timestamp(const char *t, usec_t *usec) * Allowed syntaxes: * * 2012-09-22 16:34:22 + * 2012-09-22T16:34:22 * 2012-09-22 16:34 (seconds will be set to 0) * 2012-09-22 (time will be set to 00:00:00) * 16:34:22 (date will be set to today) @@ -271,6 +272,11 @@ int parse_timestamp(const char *t, usec_t *usec) if (k && *k == 0) goto finish; + tm = copy; + k = strptime(t, "%Y-%m-%dT%H:%M:%S", &tm); + if (k && *k == 0) + goto finish; + tm = copy; k = strptime(t, "%y-%m-%d %H:%M", &tm); if (k && *k == 0) { @@ -570,13 +576,21 @@ int main(int argc, char *argv[]) char buf[ISO_BUFSIZ]; if (argc < 2) { - fprintf(stderr, "usage: %s