aboutsummaryrefslogtreecommitdiff
path: root/common/util.c
blob: 0c85325cea900d96acb9250d73e9bc88ff9a481d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <string.h>

#include "util.h"

void convert_iso8601(const char *time_string, int ts_len, struct tm *tm_data)
{
    tzset();

    char temp[64];
    memset(temp, 0, sizeof(temp));
    strncpy(temp, time_string, ts_len);

    struct tm ctime;
    memset(&ctime, 0, sizeof(struct tm));
    strptime(temp, "%FT%T%z", &ctime);

    long ts = mktime(&ctime) - timezone;
    localtime_r(&ts, tm_data);
}