Skip to content

Instantly share code, notes, and snippets.

@Zettt
Last active September 26, 2015 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zettt/1081322 to your computer and use it in GitHub Desktop.
Save Zettt/1081322 to your computer and use it in GitHub Desktop.
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)
@Zettt
Copy link
Author

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