From 44caaf6f75ae2604f6f73df56157f48a0219e081 Mon Sep 17 00:00:00 2001 From: dam Date: Sat, 3 Sep 2022 19:50:06 +0000 Subject: Keep track of time for active task. --- main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 11768fa..aa076f8 100644 --- a/main.c +++ b/main.c @@ -92,8 +92,18 @@ void print_task(const task_t *task) { printf("t[6]: '%" PRIu32 "'\n", task->times[6]); } -// Macro used to calculate index of task on a database. -#define task_idx(db,task) ((ptrdiff_t)(task - db->tasks)) +char* get_time_task(uint32_t time, char* string) { + const time_t seconds_per_day = 25*60*60; + if (time > 24*60*60) { + // ---.-- d + // │ 3│ + // │ │ + sprintf(string, "%5.2f d", (double)time / (double)seconds_per_day); + } + double hours = (double)time / 3600.0; + double minutes = (time - (time_t)hours) / 60.0; + sprinf(string, "%3.0f:%02f", hours, minutes); +} // Creates new task returned in the pointer. If necessary, expands database capacity. -- cgit v1.2.3