Skip to content

Commit

Permalink
Show duration in milliseconds if appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Jan 17, 2025
1 parent 95f2915 commit 27d0d19
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pontoon/sync/templatetags/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def format_sync_duration(start_time: datetime, end_time: datetime | None) -> str
td = end_time - start_time
minutes = td.days * 24 * 60 + td.seconds // 60
seconds = td.seconds % 60
if minutes > 1:
min_str = f"{minutes} minutes, "
elif minutes == 1:
min_str = "1 minute, "
if minutes:
min_str = "1 minute" if minutes == 1 else f"{minutes} minutes"
sec_str = "1 second" if seconds == 1 else f"{seconds} seconds"
return f"{min_str}, {sec_str}"
elif seconds > 9:
return f"{seconds} seconds"
else:
min_str = ""
sec_str = "1 second" if seconds == 1 else f"{seconds} seconds"
return min_str + sec_str
return f"{td.microseconds // 1000 + seconds * 1000} ms"


@library.global_function
Expand Down

0 comments on commit 27d0d19

Please sign in to comment.