diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-08 19:25:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-08 19:25:46 +0000 |
commit | 026db9217d89c7cc7069d663ec4ec1860c15fc39 (patch) | |
tree | 9ab5837577c95707c5babca0bd538e522bced2da /src/util | |
parent | 6878c22ebb835969239cf1792133118ccfd1afdc (diff) | |
download | gnunet-026db9217d89c7cc7069d663ec4ec1860c15fc39.tar.gz gnunet-026db9217d89c7cc7069d663ec4ec1860c15fc39.zip |
-test for tm_gmtoff and use it instead of 'timezone' as suggested by GNU libc manual
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/strings.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/util/strings.c b/src/util/strings.c index 70a1160dd..d9280a37d 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -197,7 +197,7 @@ struct ConversionTable | |||
197 | * @param input input string to parse | 197 | * @param input input string to parse |
198 | * @param table table with the conversion of unit names to numbers | 198 | * @param table table with the conversion of unit names to numbers |
199 | * @param output where to store the result | 199 | * @param output where to store the result |
200 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 200 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
201 | */ | 201 | */ |
202 | static int | 202 | static int |
203 | convert_with_table (const char *input, | 203 | convert_with_table (const char *input, |
@@ -255,7 +255,7 @@ convert_with_table (const char *input, | |||
255 | * | 255 | * |
256 | * @param fancy_size human readable string (i.e. 1 MB) | 256 | * @param fancy_size human readable string (i.e. 1 MB) |
257 | * @param size set to the size in bytes | 257 | * @param size set to the size in bytes |
258 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 258 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
259 | */ | 259 | */ |
260 | int | 260 | int |
261 | GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, | 261 | GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, |
@@ -345,6 +345,9 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, | |||
345 | { | 345 | { |
346 | struct tm tv; | 346 | struct tm tv; |
347 | time_t t; | 347 | time_t t; |
348 | #if HAVE_TM_GMTOFF | ||
349 | struct tm *tp; | ||
350 | #endif | ||
348 | 351 | ||
349 | if (0 == strcasecmp ("end of time", fancy_time)) | 352 | if (0 == strcasecmp ("end of time", fancy_time)) |
350 | { | 353 | { |
@@ -365,7 +368,10 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, | |||
365 | return GNUNET_SYSERR; | 368 | return GNUNET_SYSERR; |
366 | t = mktime (&tv); | 369 | t = mktime (&tv); |
367 | atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL); | 370 | atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL); |
368 | #if LINUX | 371 | #if HAVE_TM_GMTOFF |
372 | tp = localtime (&t); | ||
373 | atime->abs_value_us += 1000LL * 1000LL * tp->tm_gmtoff; | ||
374 | #elif defined LINUX | ||
369 | atime->abs_value_us -= 1000LL * 1000LL * timezone; | 375 | atime->abs_value_us -= 1000LL * 1000LL * timezone; |
370 | #elif defined WINDOWS | 376 | #elif defined WINDOWS |
371 | { | 377 | { |