CalculateLinearFromDate will account for the DAYS. Multiply by 24 for your TotalHours. Then to account for the Hours...

If EndDateHours > StartDateHours then TotalHours=TotalHours+(EndDateHours-StartDateHours)

If EndDateHours < StartDateHours then TotalHours=TotalHours-(StartDateHours-EndDateHours)