Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add decimal hours to timespan

I have a Decimal value representing fractional number of hours in a time interval.

Now I need to sum this value to a TimeSpan, but I cannot find an effective method to do it.

My solution, for now, is to do something like this:

myTimeSpan + new TimeSpan(0, 0, Math.Abs(decimalHours * 3600))

Is there any better way to solve my issue?

like image 580
davioooh Avatar asked Oct 04 '12 10:10

davioooh


1 Answers

how about

myTimeSPan + TimeSpan.FromHours((double)decimalHours);
like image 152
Rune FS Avatar answered Oct 02 '22 18:10

Rune FS