summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-01 17:29:01 +0800
committerꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id>2019-10-01 17:29:01 +0800
commit81843655facabb59bcd299a827b2c862dba673e0 (patch)
tree3f1864fce6b9579966531c358e43567f7ee1183a
parent8a5a9bc8101c13545f6ffe607cf8e6201c706ffc (diff)
Handle ticket history created time
into struct tm
-rw-r--r--ticket.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/ticket.c b/ticket.c
index 63e037c..fc8feb1 100644
--- a/ticket.c
+++ b/ticket.c
@@ -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)));