X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Ftw.c;h=abc98082da4d951a24f801ee4e735f2218eb98f4;hb=8d43529da6a9a3a469b107ab07f52991e9f18e75;hp=e48ab59f01ce3a43c0b04f75cddf6e593a3082e0;hpb=017d1fb012447d9b60b71e55fc637bf2422f8d5b;p=ptask.git diff --git a/src/tw.c b/src/tw.c index e48ab59..abc9808 100644 --- a/src/tw.c +++ b/src/tw.c @@ -16,11 +16,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ +#define _GNU_SOURCE #include #include #include #include +#include #include @@ -30,6 +32,17 @@ #include #include "tw.h" +struct tm *parse_time(const char *t) +{ + struct tm *tm; + + tm = malloc(sizeof(struct tm)); + memset(tm, 0, sizeof(struct tm)); + strptime(t, "%Y%m%dT%H%M%S%Z", tm); + + return tm; +} + static char *task_exec(char *opts) { FILE *f; @@ -206,6 +219,23 @@ struct task **tw_get_all_tasks(const char *status) tasks[i]->urgency = NULL; tasks[i]->note = note_get(tasks[i]->uuid); + + json = json_object_object_get(jtask, "entry"); + tasks[i]->entry = parse_time(json_object_get_string(json)); + + json = json_object_object_get(jtask, "due"); + if (json) + tasks[i]->due + = parse_time(json_object_get_string(json)); + else + tasks[i]->due = NULL; + + json = json_object_object_get(jtask, "start"); + if (json) + tasks[i]->start + = parse_time(json_object_get_string(json)); + else + tasks[i]->start = NULL; } tasks[n] = NULL; @@ -394,6 +424,9 @@ static void task_free(struct task *task) free(task->project); free(task->priority); free(task->urgency); + free(task->entry); + free(task->due); + free(task->start); free(task); }