diff options
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c new file mode 100644 index 0000000..0c85325 --- /dev/null +++ b/common/util.c @@ -0,0 +1,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); +} |