From b59cdb9849c6528922664fcc1c07537ac71e05b1 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 23 Feb 2022 12:55:55 +0100 Subject: qlop: fix date parsing of epochs on musl %s isn't a valid modifier in POSIX for strptime, so parse the number manually and produce a time out of that. Bug: https://bugs.gentoo.org/833942 Signed-off-by: Fabian Groffen --- qlop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qlop.c b/qlop.c index addb4b3..16bf69f 100644 --- a/qlop.c +++ b/qlop.c @@ -126,18 +126,18 @@ parse_date(const char *sdate, time_t *t) */ size_t len = strspn(sdate, "0123456789-:T@"); if (sdate[len] == '\0') { - const char *fmt; if (sdate[0] == '@') { - fmt = "@%s"; + time_t d = (time_t)strtoll(&sdate[1], (char **)&s, 10); + localtime_r(&d, &tm); } else if (strchr(sdate, '-') == NULL) { - fmt = "%s"; + time_t d = (time_t)strtoll(sdate, (char **)&s, 10); + localtime_r(&d, &tm); } else if ((s = strchr(sdate, 'T')) == NULL) { - fmt = "%Y-%m-%d"; + s = strptime(sdate, "%Y-%m-%d", &tm); } else { - fmt = "%Y-%m-%dT%H:%M:%S"; + s = strptime(sdate, "%Y-%m-%dT%H:%M:%S", &tm); } - s = strptime(sdate, fmt, &tm); if (s == NULL || s[0] != '\0') return false; } else { -- cgit v1.2.3-65-gdbad