Create a gist now

Instantly share code, notes, and snippets.

Inserts rounded time (15 minutes). Can be called from, e.g. TextExpander.
#!/bin/sh
hours=`date "+%H"`
let minutes=`date "+%M"`
if [[ $minutes -ge 0 ]] && [[ $minutes -le 7 ]]; then
minutes="00"
elif [[ $minutes -gt 7 ]] && [[ $minutes -le 23 ]]; then
minutes="15"
elif [[ $minutes -gt 23 ]] && [[ $minutes -le 37 ]]; then
minutes="30"
elif [[ $minutes -gt 37 ]] && [[ $minutes -le 52 ]]; then
minutes="45"
elif [[ $minutes -gt 52 ]]; then
minutes="00"
hours=$(($hours+1))
else
return "Error"
fi
printf "${hours}:${minutes}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment