updated total to use today if clocked in

main
KeeganForelight 2 years ago
parent 0a2a41c7c2
commit 5789995466

@ -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"

Loading…
Cancel
Save