p≡p engine FORK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.0 KiB

// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include "pEp_internal.h"
#include "timestamp.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
DYNAMIC_API time_t timegm_with_gmtoff(const timestamp* ts)
if (!ts)
return -1;
timestamp *_ts = timestamp_dup(ts);
if (!_ts)
return -1;
const time_t raw_time = timegm(_ts);
return -1;
return raw_time - ts->tm_gmtoff;
DYNAMIC_API timestamp * new_timestamp(time_t clock)
timestamp *ts = calloc(1, sizeof(timestamp));
if (ts == NULL)
return NULL;
if (clock)
gmtime_r(&clock, (struct tm *) ts);
return ts;
DYNAMIC_API void free_timestamp(timestamp *ts)
DYNAMIC_API timestamp * timestamp_dup(const timestamp *src)
if (!src)
return NULL;
timestamp *dst = (timestamp *) malloc(sizeof(timestamp));
memcpy(dst, src, sizeof(timestamp));
return dst;