gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: convert to GMT, not localtime in GNUNET_


From: gnunet
Subject: [gnunet] branch master updated: convert to GMT, not localtime in GNUNET_TIME_year_to_time
Date: Thu, 07 Jan 2021 22:23:59 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 4769344a7 convert to GMT, not localtime in GNUNET_TIME_year_to_time
4769344a7 is described below

commit 4769344a7a8db5a9fecab394274b9407a14a2961
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Jan 7 22:22:48 2021 +0100

    convert to GMT, not localtime in GNUNET_TIME_year_to_time
---
 configure.ac    |  2 +-
 src/util/time.c | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 530e38d88..eca988bb3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1538,7 +1538,7 @@ AC_FUNC_VPRINTF
 AC_HEADER_SYS_WAIT
 AC_TYPE_OFF_T
 AC_TYPE_UID_T
-AC_CHECK_FUNCS([atoll stat64 strnlen mremap getrlimit setrlimit sysconf 
initgroups strndup gethostbyname2 getpeerucred getpeereid setresuid 
$funcstocheck getifaddrs freeifaddrs getresgid mallinfo malloc_size 
malloc_usable_size getrusage random srandom stat statfs statvfs wait4])
+AC_CHECK_FUNCS([atoll stat64 strnlen mremap getrlimit setrlimit sysconf 
initgroups strndup gethostbyname2 getpeerucred getpeereid setresuid 
$funcstocheck getifaddrs freeifaddrs getresgid mallinfo malloc_size 
malloc_usable_size getrusage random srandom stat statfs statvfs wait4 timegm])
 
 # restore LIBS
 LIBS=$SAVE_LIBS
diff --git a/src/util/time.c b/src/util/time.c
index 5205fe11a..9e41305f1 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -716,6 +716,32 @@ GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at)
 }
 
 
+#ifndef HAVE_TIMEGM
+/**
+ * As suggested in the timegm() man page.
+ */
+static time_t
+my_timegm (struct tm *tm)
+{
+  time_t ret;
+  char *tz;
+
+  tz = getenv ("TZ");
+  setenv ("TZ", "", 1);
+  tzset ();
+  ret = mktime (tm);
+  if (tz)
+    setenv ("TZ", tz, 1);
+  else
+    unsetenv ("TZ");
+  tzset ();
+  return ret;
+}
+
+
+#endif
+
+
 /**
  * Convert a year to an expiration time of January 1st of that year.
  *
@@ -740,7 +766,11 @@ GNUNET_TIME_year_to_time (unsigned int year)
   t.tm_mon = 0;
   t.tm_wday = 1;
   t.tm_yday = 1;
-  tp = mktime (&t);
+#ifndef HAVE_TIMEGM
+  tp = my_timegm (&t);
+#else
+  tp = timegm (&t);
+#endif
   GNUNET_break (tp != (time_t) -1);
   ret.abs_value_us = tp * 1000LL * 1000LL; /* seconds to microseconds */
   return ret;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]