]>
git.ipfire.org Git - thirdparty/shadow.git/commit
lib/getdate.c: Use strptime(3) to simplify
The following trick:
t = 0;
gmtime_r(&t, &tm);
is a clever way to clear the tm(3type) structure, and set it to use UTC.
We need to set it to set UTC with this trick, because strptime(3)
doesn't set the timezone. I (Alex) tried previously using
bzero(&tm, sizeof(tm));
strptime("UTC", "%Z", &tm);
but glibc ignores the timezone, and musl (at least I tried in an Alpine
container) seems to report an error.
The idea to use gmtime_r(3) was from lanodan.
Link: <https://inbox.sourceware.org/libc-alpha/Z_LqUgildoq33vI-@cloudsdale.the-delta.net.eu.org/T/#u>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Rich Felker <dalias@libc.org>
Co-authored-by: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Signed-off-by: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Signed-off-by: Alejandro Colomar <alx@kernel.org>