Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Inserts rounded time (15 minutes). Can be called from, e.g. TextExpander. (AppleScript version)
set currentHour to hours of (current date)
set currentMinute to minutes of (current date)
if (currentHour 0) and (currentHour < 10) then
set currentHour to "0" & currentHour
end if
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)
Owner

Zettt commented Aug 14, 2013

Revision 4 adds leading 0 to hours 0-9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment