From c3a44b62d5bcf14406e1c8dd131cf6cdc342fcb1 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Wed, 28 Aug 2024 09:23:10 +0200 Subject: [PATCH] Fix crash after running Whisper - thx JDTR75 :) Related to #8755 --- src/Test/Logic/TimeCodeTest.cs | 8 ++++++++ src/libse/Common/TimeCode.cs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Test/Logic/TimeCodeTest.cs b/src/Test/Logic/TimeCodeTest.cs index 487508c22..633898468 100644 --- a/src/Test/Logic/TimeCodeTest.cs +++ b/src/Test/Logic/TimeCodeTest.cs @@ -77,6 +77,14 @@ namespace Test.Logic Assert.AreEqual(ms, new TimeSpan(0, 1, 2, 3, 990).TotalMilliseconds); } + [TestMethod] + public void TimeCodeParseToMilliseconds4() + { + var ms = TimeCode.ParseToMilliseconds("02:03:99"); + + Assert.AreEqual(ms, new TimeSpan(0, 0, 2, 3, 990).TotalMilliseconds); + } + [TestMethod] public void TimeCodeGetTotalMilliseconds() { diff --git a/src/libse/Common/TimeCode.cs b/src/libse/Common/TimeCode.cs index 3987dba84..adf42c7f2 100644 --- a/src/libse/Common/TimeCode.cs +++ b/src/libse/Common/TimeCode.cs @@ -36,7 +36,7 @@ namespace Nikse.SubtitleEdit.Core.Common if (parts.Length == 3) { - var msString = parts[3].PadRight(2, '0'); + var msString = parts[2].PadRight(2, '0'); if (int.TryParse(parts[0], out var minutes) && int.TryParse(parts[1], out var seconds) && int.TryParse(msString, out var milliseconds)) { return new TimeSpan(0, 0, minutes, seconds, milliseconds).TotalMilliseconds;