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"