I only just saw your post yesterday but thanks a lot for this. I have used yours as a starting point and made my own variant. My main change was to have it measure the time forwards from the morning which I just found easier when working out the changeover times. It works great.
In case anyone else is interested here is my ‘OmniFocus Now’ Shortcut.