Minor refactoring

This commit is contained in:
Simon Lieb 2022-05-19 19:34:17 +02:00
parent 8c03ec3bdb
commit b3acc92c1b

16
stt.c
View file

@ -300,21 +300,21 @@ timesnode_print(struct timesnode * p, time_t aftertime, time_t beforetime, int s
printf("ended at: %s", ctime(&p->endtime)); printf("ended at: %s", ctime(&p->endtime));
duration = difftime(p->endtime, p->starttime) / 3600.0; duration = difftime(p->endtime, p->starttime) / 3600.0;
duration = roundf(100.0 * duration) / 100.0;
printf("duration(hours): %.2f\n\n", duration);
} else { } else {
nowtime = malloc(sizeof(time_t));
time(nowtime);
printf("still running\n"); printf("still running\n");
duration = difftime(*nowtime, p->starttime) / 3600.0; nowtime = malloc(sizeof(time_t));
duration = roundf(100.0 * duration) / 100.0; time(nowtime);
duration = difftime(*nowtime, p->starttime) / 3600.0;
printf("duration(hours): %.2f\n\n", duration);
free(nowtime); free(nowtime);
} }
duration = roundf(100.0 * duration) / 100.0;
printf("duration(hours): %.2f\n\n", duration);
totalDuration += duration; totalDuration += duration;
} }
if (p->right != NULL) { if (p->right != NULL) {