From 578999546668e07687253f4b6973e4b22cd8e072 Mon Sep 17 00:00:00 2001 From: KeeganForelight Date: Tue, 24 Jan 2023 20:35:37 -0500 Subject: [PATCH] updated total to use today if clocked in --- timetracker.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/timetracker.sh b/timetracker.sh index ae3f539..6717560 100755 --- a/timetracker.sh +++ b/timetracker.sh @@ -99,6 +99,19 @@ totalHours() { mins=$(($mins + 10#$(echo "$time" | awk -F : '{print $2}'))) fi done < ${TIMESHEET_DIR}/${TIMESHEET} + + # if clocked in, add that hypothetical as well + if [[ -f "$CURRENT_SESSION" ]] ; then + # session exists, get info + source "$CURRENT_SESSION" + # printing to timesheet + TIME_OUT=$(date +%s) + TOTAL_TIME=$(($TIME_OUT - $TIME_IN + 3600 * 5)) + # add to total + hours=$(($TOTAL_TIME / 3600 + $hours)) + mins=$(($TOTAL_TIME / 60 + $mins)) + printf 'Today worked %s\n' $(date -d @$TOTAL_TIME +%H:%M) + fi hours=$(($hours + $mins/60)) # overflow mins=$(($mins%60)) printf 'Worked %d hours, %d minutes\n' "$hours" "$mins"