diff options
| -rw-r--r-- | main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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. |
