The fractional part of MTC corresponds to a period of 24 Martian hours.
So,
${HH \over 24} + {MM \over 60 \cdot 24} + {SS \over 60 \cdot 60 \cdot 24} = frac(MSD)$
Conversion in the opposite direction is a little more complicated: If $frac$ is the fractional part of a number, and $floor$ is the integer part (rounding by truncation), then,
$$
F_h = frac(MSD); \\
HH = floor(24 \cdot F_h) \\
F_m = frac(24 \cdot F_h) \\
MM = floor(60 \cdot F_m) \\
SS = 60 \cdot frac(60 \cdot F_m) \\
$$
Note:
- This is according to the convention o using a 24-hour "Mars clock" on which the hours, minutes and seconds are 2.7% longer than their standard (Earth) durations. That means these aren't SI system seconds - these are arbitrary periods of time corresponding to 1/(24*60*60)th of Sol.
- HH and MM are integers. SS are given as a Real, including the fractional part of the "second".
we should really find some better names for these time units