Let's say we have a 24 hour clock where all time is represented in minutes. That gives us 24 * 60 possible time points from 0 hours to 24 hours. The clockwise distance between two time points T1, T2 is simply |T1 - T2| since the time is represented in minutes.
Now, how do I obtain the counter clockwise distance between T1 and T2 ? Would I do something like
(-|T1 - T2|) % 1440?
have you considered:
24 * 60 - |T1 - T2|