Merge e8ea46f6b47bc2c2694cb4a1e3bed3c03806eb15 into c0d2f624c09dc18e709e37c2ad90c039a4eb72a2

This commit is contained in:
Gaspard Petit 2025-06-27 02:27:48 +00:00 committed by GitHub
commit d02f72858c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,7 +50,9 @@ def compression_ratio(text) -> float:
def format_timestamp(
seconds: float, always_include_hours: bool = False, decimal_marker: str = "."
):
assert seconds >= 0, "non-negative timestamp expected"
sign = "-" if seconds < 0 else ""
seconds = abs(seconds)
milliseconds = round(seconds * 1000.0)
hours = milliseconds // 3_600_000
@ -64,7 +66,7 @@ def format_timestamp(
hours_marker = f"{hours:02d}:" if always_include_hours or hours > 0 else ""
return (
f"{hours_marker}{minutes:02d}:{seconds:02d}{decimal_marker}{milliseconds:03d}"
f"{sign}{hours_marker}{minutes:02d}:{seconds:02d}{decimal_marker}{milliseconds:03d}"
)