|
|
@ -10,12 +10,21 @@ |
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
|
|
|
|
DYNAMIC_API time_t timegm_with_gmtoff(timestamp* ts) |
|
|
|
DYNAMIC_API time_t timegm_with_gmtoff(const timestamp* ts) |
|
|
|
{ |
|
|
|
const time_t raw_time = timegm(ts); |
|
|
|
if (!ts) |
|
|
|
return -1; |
|
|
|
|
|
|
|
timestamp *_ts = timestamp_dup(ts); |
|
|
|
if (!_ts) |
|
|
|
return -1; |
|
|
|
|
|
|
|
const time_t raw_time = timegm(_ts); |
|
|
|
if(raw_time==-1) |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
free_timestamp(_ts); |
|
|
|
|
|
|
|
return raw_time - ts->tm_gmtoff; |
|
|
|
} |
|
|
|
|
|
|
@ -44,11 +53,8 @@ DYNAMIC_API timestamp * timestamp_dup(const timestamp *src) |
|
|
|
if (!src) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
timestamp *dst = calloc(1, sizeof(timestamp)); |
|
|
|
assert(dst); |
|
|
|
if (!dst) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
timestamp *dst = (timestamp *) malloc(sizeof(timestamp)); |
|
|
|
memcpy(dst, src, sizeof(timestamp)); |
|
|
|
|
|
|
|
return dst; |
|
|
|
} |