def seconds2time(t):
    n, seconds = divmod(t, 60)
hours, minutes = divmod(n, 60)
return time(hours, minutes, seconds)

def timemod(a, k):
    a = time2seconds(a)
k = time2seconds(k)
res = a % k
return seconds2time(res)
print(timemod(time(20, 11, 13), time(0, 0, 10)))
print(timemod(time(20, 11, 13), time(0, 10, 0)))
Rounding time in Python