]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use %F instead of %Y-%m-%d with strftime(3)
authorAlejandro Colomar <alx@kernel.org>
Thu, 1 Aug 2024 10:32:12 +0000 (12:32 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 23 Aug 2024 03:51:57 +0000 (22:51 -0500)
%F is specified by ISO C99.  It adds semantic meaning as printing an
ISO 8601 date.

Scripted change:

$ cat ~/tmp/spatch/strftime_F.sp
@@
@@

- "%Y-%m-%d"
+ "%F"
$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/strftime_F.sp --in-place

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/time/day_to_str.h
src/chage.c

index f908a75243959615aba29ac07e88bffdff6bbfcd..b70e98975db006cb381480de150747edb10bdef3 100644 (file)
@@ -43,7 +43,7 @@ day_to_str(size_t size, char buf[size], long day)
                return;
        }
 
-       if (strftime(buf, size, "%Y-%m-%d", &tm) == 0)
+       if (strftime(buf, size, "%F", &tm) == 0)
                strtcpy(buf, "future", size);
 }
 
index 5146fde0aba3943c738673ebd90a085050e8dd16..c990953b5ca886397ded092f62d49406bb0d33be 100644 (file)
@@ -247,7 +247,7 @@ print_day_as_date(long day)
                return;
        }
 
-       STRFTIME(buf, iflg ? "%Y-%m-%d" : "%b %d, %Y", &tm);
+       STRFTIME(buf, iflg ? "%F" : "%b %d, %Y", &tm);
        (void) puts (buf);
 }