'Schedule hours in intervals. The last matching interval is truncated
to match the specified hours.
It is possible to truncate the last interval at its beginning or ending.
However this does nothing on the given interval order that should be
submitted accordingly.
:param list intervals:  a list of tuples (beginning datetime, ending datetime)
:param int/float hours: number of hours to schedule. It will be converted
into a timedelta, but should be submitted as an
int or float.
:param boolean remove_at_end: remove extra hours at the end of the last
matching interval. Otherwise, do it at the
beginning.
:return list results: a list of intervals. If the number of hours to schedule
is greater than the possible scheduling in the intervals, no extra-scheduling
is done, and results == intervals.'

def interval_schedule_hours(self, intervals, hour, remove_at_end=True):

    results = []
    res = timedelta()
    limit = timedelta(hours=hour)
    for interval in intervals:
        res += (interval[1] - interval[0])
        if ((res > limit) and remove_at_end):
            interval = (interval[0], (interval[1] + relativedelta(seconds=seconds((limit - res)))))
        elif (res > limit):
            interval = ((interval[0] + relativedelta(seconds=seconds((res - limit)))), interval[1])
        results.append(interval)
        if (res > limit):
            break
    return results
