From 77e0f26fbbf7e8c0f0de1b17368b5a27a1cbae87 Mon Sep 17 00:00:00 2001 From: Mantas Date: Tue, 30 Jan 2024 11:07:00 +0200 Subject: [PATCH] Fix srt timestamp --- src/Code/Converters/SrtConverter.php | 1 + tests/formats/SrtTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Code/Converters/SrtConverter.php b/src/Code/Converters/SrtConverter.php index 03aa24d..3f8aca5 100644 --- a/src/Code/Converters/SrtConverter.php +++ b/src/Code/Converters/SrtConverter.php @@ -130,6 +130,7 @@ public static function internalTimeToSrt($internal_time) $negative = true; $internal_time = abs($internal_time); } + $internal_time = round($internal_time, 3); $hours = floor($internal_time / 3600); $minutes = floor(((int)$internal_time % 3600) / 60); diff --git a/tests/formats/SrtTest.php b/tests/formats/SrtTest.php index b575b2f..beefd98 100644 --- a/tests/formats/SrtTest.php +++ b/tests/formats/SrtTest.php @@ -293,6 +293,7 @@ public function testConvertToSrtTime() $this->assertEquals('00:00:00,001', SrtConverter::internalTimeToSrt(0.001)); $this->assertEquals('00:00:00,010', SrtConverter::internalTimeToSrt(0.01)); $this->assertEquals('00:00:00,100', SrtConverter::internalTimeToSrt(0.1)); + $this->assertEquals('00:00:01,000', SrtConverter::internalTimeToSrt(0.9999)); $this->assertEquals('99:59:59,000', SrtConverter::internalTimeToSrt(359999)); $this->assertEquals('100:00:00,000', SrtConverter::internalTimeToSrt(360000)); }