timetracker/chug.sh

38 lines
1.1 KiB
Bash
Raw 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
[[ "${1}" == "-i" ]] && IGNORE_DO_PROCESS=1 && shift
WK_OFFSET=$1
2019-01-22 16:57:34 -05:00
WK_TOTAL=0
[[ -z ${WK_OFFSET} ]] && WK_OFFSET=0
2019-02-25 10:09:01 -05:00
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
2018-08-09 11:55:23 -04:00
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
2019-01-22 16:57:34 -05:00
else
daily_total=0
2018-08-09 11:55:23 -04:00
fi
2019-01-22 16:57:34 -05:00
echo ${daily_total}
echo
#echo -n Press ENTER for ${date}...
#read
2019-01-22 16:57:34 -05:00
WK_TOTAL=$(bc <<< "scale=2; $WK_TOTAL + $daily_total")
done
2019-01-22 16:57:34 -05:00
echo "Weekly Total: ${WK_TOTAL}"