From: Alejandro Colomar Date: Fri, 14 Feb 2025 20:25:01 +0000 (+0100) Subject: Revert "lib/, src/: Use local time for human-readable dates" X-Git-Tag: 4.17.4~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dfb2fa3c6ead1a52a1d0bbdfc08229e5fae548cf;p=thirdparty%2Fshadow.git Revert "lib/, src/: Use local time for human-readable dates" This reverts commit 3f5b4b56268269fefed55aa106f382037297d663. The dates are stored as UTC, and are stored as a number of days since Epoch. We don't have enough precision to translate it into local time. Using local time has caused endless issues in users. This patch is not enough for fixing this issue completely, since printing a date without time-zone information means that the date is a local date, but what we're printing is a UTC date. A future patch should add time-zone information to the date. For now, let's revert this change that has caused so many issues. Fixes: 3f5b4b562682 (2024-08-01; "lib/, src/: Use local time for human-readable dates") Link: Link: Link: Link: Link: Link: Link: Link: Link: Link: Reported-by: Chris Hofstaedtler Reported-by: Gus Kenion Reported-by: Alejandro Colomar Reported-by: Michael Vetter Reported-by: Lee Garrett Cc: Paul Eggert Cc: Tim Parenti Cc: "Serge E. Hallyn" Cc: Brian Inglis Reviewed-by: Iker Pedrosa Signed-off-by: Alejandro Colomar --- diff --git a/lib/time/day_to_str.h b/lib/time/day_to_str.h index b70e98975..fe3308d8c 100644 --- a/lib/time/day_to_str.h +++ b/lib/time/day_to_str.h @@ -38,7 +38,7 @@ day_to_str(size_t size, char buf[size], long day) return; } - if (localtime_r(&date, &tm) == NULL) { + if (gmtime_r(&date, &tm) == NULL) { strtcpy(buf, "future", size); return; } diff --git a/src/chage.c b/src/chage.c index aed8e5b6f..e2902a712 100644 --- a/src/chage.c +++ b/src/chage.c @@ -238,7 +238,7 @@ print_day_as_date(long day) return; } - if (localtime_r(&date, &tm) == NULL) { + if (gmtime_r(&date, &tm) == NULL) { puts(_("future")); return; }