Fix negative playtimes being considered positive

This commit is contained in:
2023-01-05 17:13:45 +01:00
parent 869e0e0fe0
commit 4e67735de8
3 changed files with 9 additions and 0 deletions

View File

@ -23,6 +23,9 @@ def format_duration(
hour_seconds = 60 * minute_seconds
day_seconds = 24 * hour_seconds
seconds_total = int(duration.total_seconds())
# timestamps where end is before start
if seconds_total < 0:
seconds_total = 0
days, remainder = divmod(seconds_total, day_seconds)
hours, remainder = divmod(remainder, hour_seconds)
minutes, seconds = divmod(remainder, minute_seconds)