diff options
| author | dam <dam@gudinoff> | 2022-09-03 19:50:06 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-09-03 19:50:06 +0000 |
| commit | 44caaf6f75ae2604f6f73df56157f48a0219e081 (patch) | |
| tree | 63a94e10ca4a71227a25c43742071306387fbd50 | |
| parent | cd2247bf832a1f210192afa3dc68cd226ae3aa02 (diff) | |
| download | task-time-tracker-44caaf6f75ae2604f6f73df56157f48a0219e081.tar.zst task-time-tracker-44caaf6f75ae2604f6f73df56157f48a0219e081.zip | |
Keep track of time for active task.
| -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. |
