Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created May 12, 2015 19:19
Show Gist options
  • Save ELLIOTTCABLE/c7a746d71649cce3620d to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/c7a746d71649cce3620d to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
netrc="${NETRC:-$HOME/.netrc}"
subdomain="${HARVEST_SUBDOMAIN:-elliottcable}"
if [ -f "$netrc" ] && [ ! -d "$netrc" ]; then
fraction="$(
curl -s --netrc-file "$netrc" \
-H 'Content-Type: application/json' -H 'Accept: application/json' \
"https://${subdomain}.harvestapp.com/daily" | \
\
jq --raw-output --exit-status 2>/dev/null \
'.day_entries | reverse | .[0] | .hours'
)" | exit $?
seconds="$(echo "(${fraction:-0} * 60 * 60) / 1" | bc)"
time="$(date -ujr "$seconds" +'%k:%M')"
printf %s\\n " $time"
else
exit 255
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment