Is there a simple way to take a float
value representing fractional hours and convert them into a TimeSpan
object and visa versa? For example:
float oneAndAHalfHours = 1.5f;
float twoHours = 2f;
float threeHoursAndFifteenMinutes = 3.25f;
float oneDayAndTwoHoursAndFortyFiveMinutes = 26.75f;
TimeSpan myTimeSpan = ConvertToTimeSpan(oneAndAHalfHours); // Should return a TimeSpan Object
Any ideas?
TimeSpan
from a number of hours, that that's whatTimeSpan.FromHours
would do? – Blindstory