Skip to content

Conversation

@alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Jul 29, 2025


Revisions:

v1b
  • Rebase
$ git rd 
1:  8d32b23b = 1:  0955b770 lib/, src/: Move gettime() prototype to "date.h"
2:  10a3ac17 = 2:  517a0bb7 lib/: date(): Add function
3:  86119094 = 3:  dfbfeb8f lib/, src/: Use date() instead of its pattern
v2
  • Move "date.h" to "time/date.h".
  • Minor include tidying.
$ git range-diff --creation-factor=99 shadow/master gh/date date 
1:  0955b770 ! 1:  fe1a5c10 lib/, src/: Move gettime() prototype to "date.h"
    @@ Metadata
     Author: Alejandro Colomar <[email protected]>
     
      ## Commit message ##
    -    lib/, src/: Move gettime() prototype to "date.h"
    +    lib/, src/: Move gettime() prototype to "time/date.h"
     
         Signed-off-by: Alejandro Colomar <[email protected]>
     
      ## lib/Makefile.am ##
     @@ lib/Makefile.am: libshadow_la_SOURCES = \
    -   console.c \
    -   copydir.c \
    -   csrand.c \
    -+  date.h \
    -   defines.h \
    -   encrypt.c \
    -   env.c \
    -
    - ## lib/date.h (new) ##
    -@@
    -+// SPDX-FileCopyrightText: 2025, Alejandro Colomar <[email protected]>
    -+// SPDX-License-Identifier: BSD-3-Clause
    -+
    -+
    -+#ifndef SHADOW_INCLUDE_LIB_DATE_H_
    -+#define SHADOW_INCLUDE_LIB_DATE_H_
    -+
    -+
    -+#include "config.h"
    -+
    -+#include <time.h>
    -+
    -+#include "defines.h"
    -+
    -+
    -+time_t gettime(void);
    -+
    -+
    -+#endif  // include guard
    +   subordinateio.h \
    +   subordinateio.c \
    +   sulog.c \
    ++  time/date.h \
    +   time/day_to_str.c \
    +   time/day_to_str.h \
    +   ttytype.c \
     
      ## lib/gettime.c ##
     @@
    @@ lib/gettime.c
      #include "config.h"
      
     -#ident "$Id$"
    -+#include "date.h"
    ++#include "time/date.h"
      
      #include <errno.h>
      #include <limits.h>
    @@ lib/prototypes.h: extern int getrange (const char *range,
      ## lib/pwd2spwd.c ##
     @@
      
    - #ident "$Id$"
    + #include "config.h"
      
    +-#ident "$Id$"
    +-
     -#include <sys/types.h>
     -#include "prototypes.h"
     -#include "defines.h"
      #include <pwd.h>
     +#include <sys/types.h>
     +
    -+#include "prototypes.h"
    -+#include "date.h"
     +#include "defines.h"
    ++#include "prototypes.h"
    ++#include "time/date.h"
      
      /*
       * pwd_to_spwd - create entries for new spwd structure
     
    + ## lib/time/date.h (new) ##
    +@@
    ++// SPDX-FileCopyrightText: 2025, Alejandro Colomar <[email protected]>
    ++// SPDX-License-Identifier: BSD-3-Clause
    ++
    ++
    ++#ifndef SHADOW_INCLUDE_LIB_TIME_DATE_H_
    ++#define SHADOW_INCLUDE_LIB_TIME_DATE_H_
    ++
    ++
    ++#include "config.h"
    ++
    ++#include <time.h>
    ++
    ++#include "defines.h"
    ++
    ++
    ++time_t gettime(void);
    ++
    ++
    ++#endif  // include guard
    +
      ## src/chpasswd.c ##
     @@
    - #endif                            /* USE_PAM */
    - #include "atoi/str2i.h"
    - #include "chkhash.h"
    -+#include "date.h"
    - #include "defines.h"
    - #include "nscd.h"
    - #include "sssd.h"
    + 
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <fcntl.h>
    + #include <getopt.h>
    + #include <pwd.h>
    +@@
    + #include "shadowlog.h"
    + #include "string/strcmp/streq.h"
    + #include "string/strtok/stpsep.h"
    ++#include "time/date.h"
    + 
    + 
    + #define IS_CRYPT_METHOD(str) ((crypt_method != NULL && streq(crypt_method, str)) ? true : false)
     
      ## src/newusers.c ##
     @@
    - #endif                            /* USE_PAM */
    - #endif                            /* ACCT_TOOLS_SETUID */
    - #include "chkname.h"
    -+#include "date.h"
    - #include "defines.h"
    - #include "getdef.h"
    - #include "groupio.h"
    + 
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <sys/types.h>
    + #include <sys/stat.h>
    + #include <stdio.h>
    +@@
    + #include "string/strdup/xstrdup.h"
    + #include "string/strtok/stpsep.h"
    + #include "string/strtok/strsep2arr.h"
    ++#include "time/date.h"
    + 
    + 
    + /*
     
      ## src/passwd.c ##
     @@
    - #include "agetpass.h"
    - #include "atoi/a2i/a2s.h"
    - #include "chkname.h"
    -+#include "date.h"
    - #include "defines.h"
    - #include "getdef.h"
    - #include "nscd.h"
    + 
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <errno.h>
    + #include <fcntl.h>
    + #include <getopt.h>
    +@@
    + #include "string/strcmp/strprefix.h"
    + #include "string/strcpy/strtcpy.h"
    + #include "string/strdup/xstrdup.h"
    ++#include "time/date.h"
    + #include "time/day_to_str.h"
    + 
    + 
     
      ## src/pwck.c ##
     @@
      
    - #include "chkname.h"
    - #include "commonio.h"
    -+#include "date.h"
    - #include "defines.h"
    - #include "getdef.h"
    - #include "nscd.h"
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <fcntl.h>
    + #include <getopt.h>
    + #include <grp.h>
    +@@
    + #include "sssd.h"
    + #include "string/strcmp/streq.h"
    + #include "string/strcmp/strprefix.h"
    ++#include "time/date.h"
    + #ifdef WITH_TCB
    + #include "tcbfuncs.h"
    + #endif                            /* WITH_TCB */
     
      ## src/pwconv.c ##
     @@
    - #include <unistd.h>
    - #include <getopt.h>
      
    -+#include "date.h"
    - #include "defines.h"
    - #include "getdef.h"
    - #include "nscd.h"
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <errno.h>
    + #include <fcntl.h>
    + #include <pwd.h>
    +@@
    + #include "shadowio.h"
    + #include "shadowlog.h"
    + #include "string/strcmp/streq.h"
    ++#include "time/date.h"
    + 
    + 
    + /*
     
      ## src/useradd.c ##
     @@
    - #include "atoi/a2i/a2s.h"
    - #include "atoi/getnum.h"
    - #include "chkname.h"
    -+#include "date.h"
    - #include "defines.h"
    - #include "faillog.h"
    - #include "fs/mkstemp/fmkomstemp.h"
    + 
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <assert.h>
    + #include <ctype.h>
    + #include <errno.h>
    +@@
    + #include "string/strcmp/strprefix.h"
    + #include "string/strdup/xstrdup.h"
    + #include "string/strtok/stpsep.h"
    ++#include "time/date.h"
    + 
    + 
    + #ifndef SKEL_DIR
     
      ## src/usermod.c ##
     @@
    - #include "atoi/a2i/a2s.h"
    - #include "atoi/getnum.h"
    - #include "chkname.h"
    -+#include "date.h"
    - #include "defines.h"
    - #include "faillog.h"
    - #include "getdef.h"
    + 
    + #include "config.h"
    + 
    +-#ident "$Id$"
    +-
    + #include <assert.h>
    + #include <ctype.h>
    + #include <errno.h>
    +@@
    + #include "string/strcmp/streq.h"
    + #include "string/strcmp/strprefix.h"
    + #include "string/strdup/xstrdup.h"
    ++#include "time/date.h"
    + #include "time/day_to_str.h"
    + #include "typetraits.h"
    + 
2:  517a0bb7 ! 2:  9f3e3425 lib/: date(): Add function
    @@ Commit message
         Signed-off-by: Alejandro Colomar <[email protected]>
     
      ## lib/Makefile.am ##
    -@@ lib/Makefile.am: libshadow_la_SOURCES = \
    -   console.c \
    -   copydir.c \
    -   csrand.c \
    -+  date.c \
    -   date.h \
    -   defines.h \
    -   encrypt.c \
     @@ lib/Makefile.am: libshadow_la_SOURCES = \
        getdef.h \
        getgr_nam_gid.c \
    @@ lib/Makefile.am: libshadow_la_SOURCES = \
        groupio.c \
        groupmem.c \
        groupio.h \
    +@@ lib/Makefile.am: libshadow_la_SOURCES = \
    +   subordinateio.h \
    +   subordinateio.c \
    +   sulog.c \
    ++  time/date.c \
    +   time/date.h \
    +   time/day_to_str.c \
    +   time/day_to_str.h \
     
    - ## lib/gettime.c => lib/date.c ##
    + ## lib/gettime.c => lib/time/date.c ##
     @@
      // SPDX-FileCopyrightText: 2017, Chris Lamb
     -// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <[email protected]>
    @@ lib/gettime.c => lib/date.c
       * gettime() returns the time as the number of seconds since the Epoch
       *
     
    - ## lib/date.h ##
    + ## lib/time/date.h ##
     @@
      #include "defines.h"
      
3:  dfbfeb8f = 3:  751b6736 lib/, src/: Use date() instead of its pattern
v3
  • Rename functions.
$ git range-diff shadow/master gh/date date 
1:  fe1a5c10 = 1:  fe1a5c10 lib/, src/: Move gettime() prototype to "time/date.h"
2:  9f3e3425 = 2:  9f3e3425 lib/: date(): Add function
3:  751b6736 = 3:  751b6736 lib/, src/: Use date() instead of its pattern
-:  -------- > 4:  48b5d40e lib/date.*: Rename gettime() => time_or_SDE()
-:  -------- > 5:  8a6047ab lib/, src/: Rename date() => date_or_SDE()
v3b
  • Reorder commits.
$ git range-diff shadow/master gh/date date 
1:  fe1a5c10 = 1:  fe1a5c10 lib/, src/: Move gettime() prototype to "time/date.h"
2:  9f3e3425 = 2:  9f3e3425 lib/: date(): Add function
3:  751b6736 = 3:  751b6736 lib/, src/: Use date() instead of its pattern
5:  8a6047ab ! 4:  9df65362 lib/, src/: Rename date() => date_or_SDE()
    @@ lib/time/date.c
     +extern inline long date_or_SDE(void);
      
      
    - // time(2) or SOURCE_DATE_EPOCH
    + /*
     
      ## lib/time/date.h ##
     @@
    @@ lib/time/date.h
      
     -inline long date(void);
     +inline long date_or_SDE(void);
    - time_t time_or_SDE(void);
    + time_t gettime(void);
      
      
     +// Like time_or_SDE(), but return a date, not a time.
4:  48b5d40e ! 5:  71b7f4a7 lib/date.*: Rename gettime() => time_or_SDE()
    @@ Commit message
     
      ## lib/time/date.c ##
     @@
    - extern inline long date(void);
    + extern inline long date_or_SDE(void);
      
      
     -/*
    @@ lib/time/date.h
     @@
      
      
    - inline long date(void);
    + inline long date_or_SDE(void);
     -time_t gettime(void);
     +time_t time_or_SDE(void);
      
      
    - inline long
    -@@ lib/time/date.h: date(void)
    + // Like time_or_SDE(), but return a date, not a time.
    +@@ lib/time/date.h: date_or_SDE(void)
      {
        time_t  t;
      
v4
  • Merge commits.
$ git range-diff shadow/master gh/date date 
1:  fe1a5c10 = 1:  fe1a5c10 lib/, src/: Move gettime() prototype to "time/date.h"
2:  9f3e3425 ! 2:  3d70bc3c lib/: date(): Add function
    @@ Metadata
     Author: Alejandro Colomar <[email protected]>
     
      ## Commit message ##
    -    lib/: date(): Add function
    +    lib/: date_or_SDE(): Add function
     
         This wrapper around gettime() returns a date (days since Epoch) instead
         of a time (seconds since Epoch).
     
    +    The name reminds that this uses SOURCE_DATE_EPOCH if available.
    +
         Signed-off-by: Alejandro Colomar <[email protected]>
     
      ## lib/Makefile.am ##
    @@ lib/gettime.c => lib/time/date.c
      #include "shadowlog.h"
      
      
    -+extern inline long date(void);
    ++extern inline long date_or_SDE(void);
     +
     +
      /*
    @@ lib/time/date.h
      #include "defines.h"
      
      
    -+inline long date(void);
    ++inline long date_or_SDE(void);
      time_t gettime(void);
      
      
    ++// Like time_or_SDE(), but return a date, not a time.
     +inline long
    -+date(void)
    ++date_or_SDE(void)
     +{
     +  time_t  t;
     +
3:  751b6736 ! 3:  f42ba6ee lib/, src/: Use date() instead of its pattern
    @@ Metadata
     Author: Alejandro Colomar <[email protected]>
     
      ## Commit message ##
    -    lib/, src/: Use date() instead of its pattern
    +    lib/, src/: Use date_or_SDE() instead of its pattern
     
         The checks changing 0 into -1 were probably added because gettime()/DAY
         transformed a gettime() error code (-1) into 0, due to integer division.
     
    -    Now that we use date(), which reports errors with -1, this won't happen.
    +    Now that we use date_or_SDE(), which reports errors with -1, this won't
    +    happen.
     
         It could also happen that the date is 0 (so the day is the Epoch), but
         this is unlikely, and anyway, I don't see any reasons to special-case
    @@ lib/pwd2spwd.c: struct spwd *pwd_to_spwd (const struct passwd *pw)
     -                   * change */
     -                  sp.sp_lstchg = -1;
     -          }
    -+          sp.sp_lstchg = date();
    ++          sp.sp_lstchg = date_or_SDE();
        }
      
        /*
    @@ src/chpasswd.c: int main (int argc, char **argv)
     -                           * password change */
     -                          newsp.sp_lstchg = -1;
     -                  }
    -+                  newsp.sp_lstchg = date();
    ++                  newsp.sp_lstchg = date_or_SDE();
                }
      
                if (   (NULL == sp)
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
     -                   * change */
     -                  spent.sp_lstchg = -1;
     -          }
    -+          spent.sp_lstchg = date();
    ++          spent.sp_lstchg = date_or_SDE();
                return (spw_update (&spent) == 0);
        }
      
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
     -          /* Better disable aging than requiring a password change */
     -          spent.sp_lstchg = -1;
     -  }
    -+  spent.sp_lstchg = date();
    ++  spent.sp_lstchg = date_or_SDE();
        spent.sp_min    = getdef_num ("PASS_MIN_DAYS", 0);
        /* 10000 is infinity this week */
        spent.sp_max    = getdef_num ("PASS_MAX_DAYS", 10000);
    @@ src/passwd.c: static void update_shadow (void)
     -                  }
     -          }
     +          if (do_update_age)
    -+                  nsp->sp_lstchg = date();
    ++                  nsp->sp_lstchg = date_or_SDE();
        }
      
        /*
    @@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
     -                                           */
     -                                          sp.sp_lstchg = -1;
     -                                  }
    -+                                  sp.sp_lstchg = date();
    ++                                  sp.sp_lstchg = date_or_SDE();
                                        *changed = true;
      
                                        if (spw_update (&sp) == 0) {
    @@ src/pwconv.c: int main (int argc, char **argv)
     -                   * change */
     -                  spent.sp_lstchg = -1;
     -          }
    -+          spent.sp_lstchg = date();
    ++          spent.sp_lstchg = date_or_SDE();
                if (spw_update (&spent) == 0) {
                        fprintf (stderr,
                                 _("%s: failed to prepare the new %s entry '%s'\n"),
    @@ src/useradd.c: static void new_spent (struct spwd *spent)
     -          /* Better disable aging than requiring a password change */
     -          spent->sp_lstchg = -1;
     -  }
    -+  spent->sp_lstchg = date();
    ++  spent->sp_lstchg = date_or_SDE();
        if (!rflg) {
                spent->sp_min = getdef_num ("PASS_MIN_DAYS", -1);
                spent->sp_max = getdef_num ("PASS_MAX_DAYS", -1);
    @@ src/usermod.c: static void new_spent (struct spwd *spent)
     -          }
     -  }
     +  if (pflg)
    -+          spent->sp_lstchg = date();
    ++          spent->sp_lstchg = date_or_SDE();
      }
      
      /*
    @@ src/usermod.c: static void usr_update (void)
     -                           * requiring a password change */
     -                          spent.sp_lstchg = -1;
     -                  }
    -+                  spent.sp_lstchg = date();
    ++                  spent.sp_lstchg = date_or_SDE();
                        spent.sp_min    = getdef_num ("PASS_MIN_DAYS", -1);
                        spent.sp_max    = getdef_num ("PASS_MAX_DAYS", -1);
                        spent.sp_warn   = getdef_num ("PASS_WARN_AGE", -1);
4:  9df65362 < -:  -------- lib/, src/: Rename date() => date_or_SDE()
5:  71b7f4a7 = 4:  ec089fed lib/date.*: Rename gettime() => time_or_SDE()
$ git diff gh/date..date 
$
v5
  • gettime() can't fail.
$ git range-diff shadow/master gh/date date 
1:  fe1a5c10 = 1:  fe1a5c10 lib/, src/: Move gettime() prototype to "time/date.h"
2:  3d70bc3c ! 2:  30c33f86 lib/: date_or_SDE(): Add function
    @@ lib/time/date.h
     +inline long
     +date_or_SDE(void)
     +{
    -+  time_t  t;
    -+
    -+  t = gettime();
    -+  if (t == -1)
    -+          return -1;
    -+
    -+  return t / DAY;
    ++  return gettime() / DAY;
     +}
     +
     +
3:  f42ba6ee ! 3:  aae1c104 lib/, src/: Use date_or_SDE() instead of its pattern
    @@ Commit message
     
         The checks changing 0 into -1 were probably added because gettime()/DAY
         transformed a gettime() error code (-1) into 0, due to integer division.
    -
    -    Now that we use date_or_SDE(), which reports errors with -1, this won't
    -    happen.
    +    That was dead code: gettime() can't fail.
     
         It could also happen that the date is 0 (so the day is the Epoch), but
         this is unlikely, and anyway, I don't see any reasons to special-case
4:  ec089fed ! 4:  580ff8ed lib/date.*: Rename gettime() => time_or_SDE()
    @@ lib/time/date.h
      
      
      // Like time_or_SDE(), but return a date, not a time.
    -@@ lib/time/date.h: date_or_SDE(void)
    + inline long
    + date_or_SDE(void)
      {
    -   time_t  t;
    +-  return gettime() / DAY;
    ++  return time_or_SDE() / DAY;
    + }
      
    --  t = gettime();
    -+  t = time_or_SDE();
    -   if (t == -1)
    -           return -1;
      
v5b
$ git range-diff fe1a5c104041^..gh/date shadow/master..date
1:  fe1a5c10 = 1:  c80e8eb8 lib/, src/: Move gettime() prototype to "time/date.h"
2:  30c33f86 = 2:  26caef76 lib/: date_or_SDE(): Add function
3:  aae1c104 = 3:  580255bb lib/, src/: Use date_or_SDE() instead of its pattern
4:  580ff8ed = 4:  572c7fd2 lib/date.*: Rename gettime() => time_or_SDE()
v5c
  • Rebase
$ git rd
1:  c80e8eb8 = 1:  7eb728fc lib/, src/: Move gettime() prototype to "time/date.h"
2:  26caef76 = 2:  77fcba01 lib/: date_or_SDE(): Add function
3:  580255bb = 3:  e16e5bc9 lib/, src/: Use date_or_SDE() instead of its pattern
4:  572c7fd2 = 4:  5707a9d5 lib/date.*: Rename gettime() => time_or_SDE()
v5d
  • Rebase
$ git rd 
1:  7eb728fc ! 1:  6be3fffc lib/, src/: Move gettime() prototype to "time/date.h"
    @@ src/newusers.c
      #include "string/strtok/strsep2arr.h"
     +#include "time/date.h"
      
    - 
    - /*
    + struct option_flags {
    +   bool chroot;
     
      ## src/passwd.c ##
     @@
2:  77fcba01 = 2:  ca1063a0 lib/: date_or_SDE(): Add function
3:  e16e5bc9 ! 3:  e5254378 lib/, src/: Use date_or_SDE() instead of its pattern
    @@ src/newusers.c: static int add_passwd (struct passwd *pwd, const char *password)
        spent.sp_max    = getdef_num ("PASS_MAX_DAYS", 10000);
     
      ## src/passwd.c ##
    -@@ src/passwd.c: static void update_shadow (void)
    +@@ src/passwd.c: static void update_shadow (struct option_flags *flags)
        }
        if (!use_pam)
        {
    @@ src/passwd.c: static void update_shadow (void)
        /*
     
      ## src/pwck.c ##
    -@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed)
    +@@ src/pwck.c: static void check_pw_file (bool *errors, bool *changed, struct option_flags *fla
                                        sp.sp_inact  = -1;
                                        sp.sp_expire = -1;
                                        sp.sp_flag   = SHADOW_SP_FLAG_UNSET;
    @@ src/useradd.c: static void new_spent (struct spwd *spent)
                spent->sp_max = getdef_num ("PASS_MAX_DAYS", -1);
     
      ## src/usermod.c ##
    -@@ src/usermod.c: static void new_spent (struct spwd *spent)
    +@@ src/usermod.c: static void new_spent (struct spwd *spent, bool process_selinux)
         */
        spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
      
    @@ src/usermod.c: static void new_spent (struct spwd *spent)
      }
      
      /*
    -@@ src/usermod.c: static void usr_update (void)
    +@@ src/usermod.c: static void usr_update (struct option_flags *flags)
                        spent.sp_pwdp   = xstrdup (pwent.pw_passwd);
                        pwent.pw_passwd = xstrdup (SHADOW_PASSWD_STRING);
      
4:  5707a9d5 = 4:  a63d4992 lib/date.*: Rename gettime() => time_or_SDE()
v5e
  • Rebase
$ git rd 
1:  6be3fffc4 ! 1:  72a266088 lib/, src/: Move gettime() prototype to "time/date.h"
    @@ src/newusers.c
      #include <sys/stat.h>
      #include <stdio.h>
     @@
    - #include "string/strdup/xstrdup.h"
    + #include "string/strdup/strdup.h"
      #include "string/strtok/stpsep.h"
      #include "string/strtok/strsep2arr.h"
     +#include "time/date.h"
    @@ src/passwd.c
     @@
      #include "string/strcmp/strprefix.h"
      #include "string/strcpy/strtcpy.h"
    - #include "string/strdup/xstrdup.h"
    + #include "string/strdup/strdup.h"
     +#include "time/date.h"
      #include "time/day_to_str.h"
      
    @@ src/useradd.c
      #include <errno.h>
     @@
      #include "string/strcmp/strprefix.h"
    - #include "string/strdup/xstrdup.h"
    + #include "string/strdup/strdup.h"
      #include "string/strtok/stpsep.h"
     +#include "time/date.h"
      
    @@ src/usermod.c
     @@
      #include "string/strcmp/streq.h"
      #include "string/strcmp/strprefix.h"
    - #include "string/strdup/xstrdup.h"
    + #include "string/strdup/strdup.h"
     +#include "time/date.h"
      #include "time/day_to_str.h"
      #include "typetraits.h"
2:  ca1063a0d = 2:  e5885598a lib/: date_or_SDE(): Add function
3:  e5254378e = 3:  7ec8268fb lib/, src/: Use date_or_SDE() instead of its pattern
4:  a63d49922 = 4:  81d44a507 lib/date.*: Rename gettime() => time_or_SDE()

This wrapper around gettime() returns a date (days since Epoch) instead
of a time (seconds since Epoch).

The name reminds that this uses SOURCE_DATE_EPOCH if available.

Signed-off-by: Alejandro Colomar <[email protected]>
The checks changing 0 into -1 were probably added because gettime()/DAY
transformed a gettime() error code (-1) into 0, due to integer division.
That was dead code: gettime() can't fail.

It could also happen that the date is 0 (so the day is the Epoch), but
this is unlikely, and anyway, I don't see any reasons to special-case
that date.

Signed-off-by: Alejandro Colomar <[email protected]>
This makes it more consistent.  gettime() made it look as if it had some
relation with getdate(3), which it doesn't.  It's essentially time(2),
but reading SOURCE_DATE_EPOCH if available.

Also rename several local variables for readability.

Signed-off-by: Alejandro Colomar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant