You are given a time in the format "HH:MM", representing a 24-hour clock time with hours and minutes. Extend this to potentially include seconds and milliseconds as follow-ups.
time
in the format
"HH:MM"
, where:
0 <= HH <= 23
0 <= MM <= 59
"HH:MM:SS"
, with:
0 <= SS <= 59
"HH:MM:SS.mmm"
, with:
0 <= mmm <= 999
Specify the formulas you would use for the hand positions, how you handle 24-hour times on a 12-hour clock face, and then implement a function that returns the minimal angle between the two hands as a floating point value.
Input: a time string in one of the above formats. Output: the smallest angle between the hour and minute hands, in degrees (a floating point number).
Describe the algorithm and then implement it in your preferred programming language.