commit 026db9217d89c7cc7069d663ec4ec1860c15fc39
parent 6878c22ebb835969239cf1792133118ccfd1afdc
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 8 Dec 2013 19:25:46 +0000
-test for tm_gmtoff and use it instead of 'timezone' as suggested by GNU libc manual
Diffstat:
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -203,6 +203,13 @@ AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(m, log)
AC_CHECK_LIB(c, getloadavg, AC_DEFINE(HAVE_GETLOADAVG,1,[getloadavg supported]))
+
+AC_CHECK_MEMBER(struct tm.tm_gmtoff,
+ [AC_DEFINE(HAVE_TM_GMTOFF, 1,
+ [Define if struct tm has the tm_gmtoff member.])],
+ ,
+ [#include <time.h>])
+
# 'save' libs; only those libs found so far will be
# linked against _everywhere_. For the others, we
# will be more selective!
diff --git a/src/util/strings.c b/src/util/strings.c
@@ -197,7 +197,7 @@ struct ConversionTable
* @param input input string to parse
* @param table table with the conversion of unit names to numbers
* @param output where to store the result
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
static int
convert_with_table (const char *input,
@@ -255,7 +255,7 @@ convert_with_table (const char *input,
*
* @param fancy_size human readable string (i.e. 1 MB)
* @param size set to the size in bytes
- * @return GNUNET_OK on success, GNUNET_SYSERR on error
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
*/
int
GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size,
@@ -345,6 +345,9 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
{
struct tm tv;
time_t t;
+#if HAVE_TM_GMTOFF
+ struct tm *tp;
+#endif
if (0 == strcasecmp ("end of time", fancy_time))
{
@@ -365,7 +368,10 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time,
return GNUNET_SYSERR;
t = mktime (&tv);
atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
-#if LINUX
+#if HAVE_TM_GMTOFF
+ tp = localtime (&t);
+ atime->abs_value_us += 1000LL * 1000LL * tp->tm_gmtoff;
+#elif defined LINUX
atime->abs_value_us -= 1000LL * 1000LL * timezone;
#elif defined WINDOWS
{