<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def timedeltaToString(delta):
 """ Convert timedelta to an ical DURATION. """

    if delta.days == 0:
        sign = 1
    else:
        sign = delta.days / abs(delta.days)
    delta = abs(delta)
    days = delta.days
    hours = int(delta.seconds / 3600)
    minutes = int((delta.seconds % 3600) / 60)
    seconds = int(delta.seconds % 60)

    output = ''
    if sign == -1:
        output += '-'
    output += 'P'
    if days:
        output += '{}D'.format(days)
    if hours or minutes or seconds:
        output += 'T'
    elif not days:  # Deal with zero duration
        output += 'T0S'
    if hours:
        output += '{}H'.format(hours)
    if minutes:
        output += '{}M'.format(minutes)
    if seconds:
        output += '{}S'.format(seconds)
    return output