Skip to content

Instantly share code, notes, and snippets.

@Zettt
Created February 2, 2011 20:56
Show Gist options
  • Save Zettt/808416 to your computer and use it in GitHub Desktop.
Save Zettt/808416 to your computer and use it in GitHub Desktop.
Short TextExpander snippet to round the current time to a quarter hour.
set currentHour to hours of (current date)
set currentMinute to minutes of (current date)
if (currentMinute ≥ 0) and (currentMinute ≤ 7) then
set currentMinute to "00"
else if (currentMinute > 7) and (currentMinute ≤ 23) then
set currentMinute to "15"
else if (currentMinute > 23) and (currentMinute ≤ 37) then
set currentMinute to "30"
else if (currentMinute > 37) and (currentMinute ≤ 52) then
set currentMinute to "45"
else if (currentMinute > 52) then
set currentMinute to "00"
set currentHour to currentHour + 1
else
return "Error"
end if
return (currentHour as string) & ":" & (currentMinute as string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment