Does anybody have suggestions for the most efficient way to round the current time to the nearest 6-minute increment (i.e. XX:06, XX:12, XX:18, etc.)?

I could write a very long shortcut to do this with built-in calculate steps, but I’m wondering if PCalc, or some other app (or built-in action) can do this more easily. Suggestions welcome.

You also have to deal with adding leading zeros back in when re-assembling the time following the calculations.

It can be done pretty efficiently in most any code (I’ve written some javascript versions myself), But replicating that code in Shortcuts takes a ton of steps, so I was wondering if there was some app that did it more efficiently.

If anybody knows of one, please let me know. (Otherwise, I’ll either write it up as a separate shortcut, or maybe a scriptable script or something).

Thanks.

In short, it very doable, but a big pain. That’s why I’m wondering if there’s some app that would make this trivial.

Just out of curiosity I tried to solve this problem. It took me only 8 actions with without any zero padding or handling the full hour on its own. I simply add the difference between the wanted 6 minute interval and the saved time to the saved time: https://www.icloud.com/shortcuts/07a76ded3d9d43e0a9ed11ad36406004 (Warning, iOS 12 shortcut)

In short: get minutes, divide by 6, round, multiply by 6, subtract initial minutes, add that as minutes to the original date

Just for completeness then, try this. It’s written on iOS12, but hopefully it’s 13 compatible, and it may even be possible to streamline further in 13. But as it stands I’ve got it down to three native Shortcuts steps to do the rounding plus a fourth to ask for the time to run the example

I don’t know if it’ll qualify as “best”, but relatively brief and entirely native I think is at least reasonable - assuming it works as expected of course

Thank you for this. I have no interest in rounding times, but the data URL technique in your shortcut just solved a problem I’ve been chewing on all day. Making a <script> to run through Safari is a great way to get JavaScript solutions that rely on large external libraries.