commit bc1401cbad9f4b2780e519a4a652f13fbf566b33 parent 751ba602cedd1eebeddd72cfc2f301a59037310d Author: Alex Balgavy <a.balgavy@gmail.com> Date: Mon, 29 Jul 2019 23:20:32 +0200 track: more output & track duration Former-commit-id: 12fc11cc5561adcafcb9cc8beb2708385e66bbee Diffstat:
M | scripts/track | | | 16 | ++++++++++++++-- |
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/scripts/track b/scripts/track @@ -7,6 +7,18 @@ if [ $# -eq 0 ]; then date +%s > .timetrackfile echo "Tracking time." elif [ "$1" = "stop" ]; then - echo "Complete: $(expr $(date +%s) - $(cat .timetrackfile))" - rm .timetrackfile + start_time_s=$(cat .timetrackfile && rm .timetrackfile) + end_time_s=$(date +%s) + duration_s=$(($end_time_s - $start_time_s)) + start_fmt=$(date -r $start_time_s +%H:%M) + end_fmt=$(date -r $end_time_s +%H:%M) + hours=$(($duration_s / 3600)) + minutes=$((($duration_s % 3600)/60)) + duration_fmt="$(printf "%02d" $hours):$(printf "%02d" $minutes)" + + echo "Complete." + echo "Start: $start_fmt" + echo "End: $end_fmt" + echo "Duration: $duration_s, $duration_fmt" + echo "$(date +%d-%m-%Y),$start_fmt,$end_fmt,$duration_fmt" fi