diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-01 17:29:01 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-10-01 17:29:01 +0800 |
commit | 81843655facabb59bcd299a827b2c862dba673e0 (patch) | |
tree | 3f1864fce6b9579966531c358e43567f7ee1183a /ticket.c | |
parent | 8a5a9bc8101c13545f6ffe607cf8e6201c706ffc (diff) |
Handle ticket history created time
into struct tm
Diffstat (limited to 'ticket.c')
-rw-r--r-- | ticket.c | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -181,19 +181,35 @@ static size_t history_handler(void *contents, size_t size, size_t nmemb = malloc(strlen(token)); strcpy(ticket_history->creator, ++token); } else if (!strcmp(token, "Created")) { - token = strtok_r(NULL, ":", &tokensaveptr); -#ifdef DEBUG - printf("Created: %s\n", token); -#endif - /* ticket_history->created = malloc(sizeof(struct tm)); - */ + ticket_history->created->tm_isdst = -1; + token = strtok_r(NULL, ":", &tokensaveptr); + char *tmsaveptr = NULL; + char *tm = strtok_r(token, " " + , &tmsaveptr); + char *datesaveptr = NULL; + char *date = strtok_r(tm, "-" + , &datesaveptr); + ticket_history->created->tm_year + = atoi(date) - 1900; + date = strtok_r(NULL, "-", &datesaveptr); + ticket_history->created->tm_mon + = atoi(date) - 1; + date = strtok_r(NULL, "-", &datesaveptr); + ticket_history->created->tm_mday + = atoi(date); + tm = strtok_r(NULL, " ", &tmsaveptr); + ticket_history->created->tm_hour + = atoi(tm); + token = strtok_r(NULL, ":", &tokensaveptr); + ticket_history->created->tm_min + = atoi(token); + token = strtok_r(NULL, ":", &tokensaveptr); + ticket_history->created->tm_sec + = atoi(token); } else if (!strcmp(token, "Attachments")) { token = strtok_r(NULL, ":", &tokensaveptr); -#ifdef DEBUG - printf("Attachments: %s\n", token); -#endif break; } } while ((line = strtok_r(NULL, "\n", &linesaveptr))); |