Skip to content

Commit

Permalink
Revert "lib/, src/: Use local time for human-readable dates"
Browse files Browse the repository at this point in the history
This reverts commit 3f5b4b5.

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: 3f5b4b5 (2024-08-01; "lib/, src/: Use local time for human-readable dates")
Link: <https://github.com/ansible/ansible/blob/devel/test/integration/targets/user/tasks/test_expires.yml#L2-L20>
Link: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1095430>
Link: <https://lists.iana.org/hyperkitty/list/[email protected]/message/ENE5IFV3GAH6WK22UJ6YU57D6TQINSP5/>
Link: <#1202>
Link: <#1057>
Link: <#939>
Link: <#1058>
Link: <#1059 (comment)>
Link: <#952>
Link: <#942>
Reported-by: Chris Hofstaedtler <[email protected]>
Reported-by: Gus Kenion <https://github.com/kenion>
Reported-by: Alejandro Colomar <[email protected]>
Reported-by: Michael Vetter <[email protected]>
Reported-by: Lee Garrett <[email protected]>
Cc: Paul Eggert <[email protected]>
Cc: Tim Parenti <[email protected]>
Cc: "Serge E. Hallyn" <[email protected]>
Cc: Brian Inglis <[email protected]>
Reviewed-by: Iker Pedrosa <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Feb 25, 2025
1 parent 77eb67d commit a0c5dbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/time/day_to_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/chage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a0c5dbd

Please sign in to comment.