Last active
December 3, 2024 11:03
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision 4 adds leading 0 to hours 0-9.