timekeeper

[Abandoned unfinished] CGI web application in C for time tracking. (My first, just a learning project)
Log | Files | Refs | README

commit 30beeae0a524473b78a9c7a0c10983f6660d4dff
parent 4b5eea23842388143bd97a3f4faad1f77cda01e2
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Sun, 17 Mar 2024 17:36:18 -0700

Add period to timesheet struct

Diffstat:
Mstmt.c | 2+-
Mtimes.c | 7+++++--
Mtimes.h | 1+
3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/stmt.c b/stmt.c @@ -69,7 +69,7 @@ struct sqlbox_pstmt pstmts[] = { " (SELECT (entry) FROM current_entries WHERE userid IS ?)" }, [StmtGetTimes] = { .stmt = - "SELECT start, startbreak, endbreak, end FROM times\n" + "SELECT period, start, startbreak, endbreak, end FROM times\n" " WHERE userid IS ? AND period ISNULL" }, [StmtBreakTime] = { .stmt = diff --git a/times.c b/times.c @@ -139,12 +139,15 @@ gettimes(struct pagedata *pd, char *hash, struct timesheet **rtimes) else if (oldtime) inserttimesheet(time, oldtime); - for (i = 0; i < 4; ++i) { + for (i = 0; i < 5; ++i) { switch (r->ps[i].type) { case SQLBOX_PARM_NULL: break; case SQLBOX_PARM_INT: - timesheet_set(time, i, r->ps[i].iparm); + if (i == 0) + time->period = r->ps[i].iparm; + else + timesheet_set(time, i - 1, r->ps[i].iparm); break; default: err(1, "This is a stmt.c bug"); diff --git a/times.h b/times.h @@ -17,6 +17,7 @@ struct timesheet; struct timesheet { time_t times[4]; /* raw time data */ enum time_flag set; /* which times are set */ + int period; /* period of the times, <0 if not set */ struct timesheet *prev, *next; /* previous and next entry */ };