aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c14
1 files 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.