aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2022-02-23 12:55:55 +0100
committerFabian Groffen <grobian@gentoo.org>2022-02-23 12:55:55 +0100
commitb59cdb9849c6528922664fcc1c07537ac71e05b1 (patch)
tree143fedb08d5decccacd378d36b6af4788fe89a01
parentautotools: update gnulib (diff)
downloadportage-utils-b59cdb9849c6528922664fcc1c07537ac71e05b1.tar.gz
portage-utils-b59cdb9849c6528922664fcc1c07537ac71e05b1.tar.bz2
portage-utils-b59cdb9849c6528922664fcc1c07537ac71e05b1.zip
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 <grobian@gentoo.org>
-rw-r--r--qlop.c12
1 files 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 {