<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def businesstimedelta(self, d1, d2):
 """ Returns a datetime.timedelta with the number of full business days and business time between d1 and d2 """


        if d1 > d2:
            d1, d2, timedelta_direction = d2, d1, -1
        else:
            timedelta_direction = 1
        businessdays = self._build_spanning_datetimes(d1, d2)
        time = datetime.timedelta()

        if len(businessdays) == 0:
            # HACK: manually handle the case when d1 is after business hours while d2 is during
            if self.isduringbusinesshours(d2):
                time += d2 - datetime.datetime.combine(d2,
                                                       self.business_hours[0])

            # HACK: manually handle the case where d1 is on an earlier non-business day and d2 is after hours on a business day
            elif not self.isbusinessday(d1) and self.isbusinessday(d2):
                if d2.time() > self.business_hours[1]:
                    time += datetime.datetime.combine(
                        d2,
                        self.business_hours[1]) - datetime.datetime.combine(
                            d2, self.business_hours[0])
                elif d2.time() > self.business_hours[0]:
                    time += d2 - datetime.datetime.combine(
                        d2, self.business_hours[0])

        else:
            prev = None
            current = None
            count = 0
            for d in businessdays:
                if current is None:
                    current = d
                current = datetime.datetime.combine(d, current.time())
                if prev is not None:
                    if prev.date() != current.date():
                        time += datetime.timedelta(days=1)
                    if count == len(businessdays) - 1:
                        if current > d:
                            # We went too far
                            time -= datetime.timedelta(days=1)
                            time += self.open_hours - (current - d)
                        else:
                            time += d - current
                count += 1
                prev = current

        return time * timedelta_direction