Skip to content

Instantly share code, notes, and snippets.

@Zettt
Created July 13, 2011 21:01
Show Gist options
  • Save Zettt/1081320 to your computer and use it in GitHub Desktop.
Save Zettt/1081320 to your computer and use it in GitHub Desktop.
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