0e8b1724da5c8472e3527f10619d3978025e169d
galt
  Thu Feb 3 20:20:51 2022 -0800
Since MacOS and BSDs have the Linux-originated function timegm now, we are free to use it. Even though I loved the other function and could prove its correctness, this is simple and reliable.

diff --git src/lib/common.c src/lib/common.c
index c5f803f..ae70a18 100644
--- src/lib/common.c
+++ src/lib/common.c
@@ -3730,35 +3730,35 @@
 
 boolean isAllDigits(char *s)
 /* Return TRUE if string is non-empty and contains only digits (i.e. is a nonnegative integer). */
 {
 if (isEmpty(s))
     return FALSE;
 char c;
 while ((c = *s++) != 0)
     if (!isdigit(c))
         return FALSE;
 return TRUE;
 }
 
 
 time_t mktimeFromUtc(struct tm *tm)
+// convert UTC time to UTC time_t 
+// The timegm function is available on Linux and BSD and MacOS/Darwin
+// This is thread-safe and avoids setenv
 {
-time_t ret = tm->tm_sec + tm->tm_min*60 + tm->tm_hour*3600 + tm->tm_yday*86400;
-ret += ((time_t)31536000) * (tm->tm_year-70);
-ret += ((tm->tm_year-69)/4)*86400 - ((tm->tm_year-1)/100)*86400 + ((tm->tm_year+299)/400)*86400;
-return ret;
+return timegm(tm);
 }
 
 
 time_t dateToSeconds(const char *date,const char*format)
 // Convert a string date to time_t
 {
 struct tm storage={0,0,0,0,0,0,0,0,0};
 if (strptime(date,format,&storage)==NULL)
     return 0;
 else
     return mktime(&storage);
 }
 
 boolean dateIsOld(const char *date,const char*format)
 // Is this string date older than now?