Code to convert work hours wraps to 24 hours?
<p>I have some code which takes for example, 27:30 (27 hours 30 minutes) and converts it to a decimal like 27.5. I have another function that does the opposite.</p>

<pre><code> public class Time
    {
        public static string Hours(decimal d)
        {
            return TimeSpan.FromHours((double)(d + 0.005M)).ToString("h\\:mm");
        }

        public static decimal Hours(string s)
        {
            decimal r;
            if (decimal.TryParse(s, out r))
                return r;

            return (decimal)TimeSpan.Parse(s).TotalHours + 0.005M;
        }
    }
</code></pre>

<p>The problem is that the conversion from decimal to string seems to wrap to 24 hours. If I give it 30.0 it gives me 6:00 which is wrong. It should be 30:00</p>

<p>What could I do to avoid the wrap?</p>

<p>Thanks</p>
