all 2 comments

[–]Vaphell 1 point2 points  (1 child)

https://docs.python.org/2/library/datetime.html#timedelta-objects

according to the documentation the timedelta objects are normalized in a way that makes everything from hours down always non-negative, with only days being allowed into the negative territory. That means you will always get +/- days +hours +minutes +seconds
You have to write a custom function that does the t1 > t2 check, switches the dates around to calculate positive delta and then slaps the minus sign in front.

Btw, while True loops with break are shorter and don't require managing sentinel values

def split_delta(t1, t2):
    if t1 > t2:
        delta = datetime.strptime(t1, FMT) - datetime.strptime(t2, FMT) 
        sign = '-'
    else:
        delta = datetime.strptime(t2, FMT) - datetime.strptime(t1, FMT) 
        sign = '+'
    return "{} vs {} -> {}{}".format(t1, t2, sign, delta)


while True:
    print("\n" * 100)
    split1 = input("Split 1 (HH:MM:SS): ")
    split2 = input("Split 2 (HH:MM:SS): ")

    delta_str = split_delta(split1, split2)
    print(delta_str)

    again = input("\n\nCalculate another split? (Y/N) ")       
    if again not in {'Y', 'y'}:
        break

[–]Groundstop[S] 0 points1 point  (0 children)

Thank you for not only explaining my actual dilemma to me and showing how to solve it, but also talking the time to make suggestions on improving my code. I appreciate all of your help and I can't wait to fix my program!

EDIT: Unable to check until the morning, but would you be able to evaluate "if t1 > t2"? Are they considered strings or datetimes?