timetracker/chug.sh

39 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/zsh
PATH=/Users/tblancher/bin:/Users/tblancher/homebrew/opt/coreutils/libexec/gnubin:/Users/tblancher/homebrew/opt/grep/libexec/gnubin:/usr/bin:/bin
IGNORE_DO_PROCESS=1
[[ "${1}" == "-d" ]] && IGNORE_DO_PROCESS=0 && shift
WK_OFFSET=$1
WK_TOTAL=0
[[ -z ${WK_OFFSET} ]] && WK_OFFSET=0
DATE=$(date -d "last Monday - ${WK_OFFSET} weeks")
for date in $(date +%F -d "${DATE}") \
$(date +%F -d "${DATE} + 1 day") \
$(date +%F -d "${DATE} + 2 day") \
$(date +%F -d "${DATE} + 3 day") \
$(date +%F -d "${DATE} + 4 day") \
$(date +%F -d "${DATE} + 5 day") \
$(date +%F -d "${DATE} + 6 day"); do
echo $date
if [[ -f ${date}.log ]]; then
[[ -n $IGNORE_DO_PROCESS ]] || ./do_process.sh ${date}.log | less
daily_total=$(./do_process.sh ${date}.log | grep -P "Grand total:" | grep -Po "\d+\.\d+")
if [[ ${daily_total} -gt 24 ]]; then
daily_total=24.00
fi
else
daily_total=0
fi
echo ${daily_total}
echo
#echo -n Press ENTER for ${date}...
#read
WK_TOTAL=$(bc <<< "scale=2; $WK_TOTAL + $daily_total")
done
echo "Weekly Total: ${WK_TOTAL}"