Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conversion of timestamps in 3 decimal places #79

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LrcParser.Tests/Parser/Lrc/Utils/LrcStartTimeUtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void TestDecodeWithInvalidLine(string line, int[] expectedStartTimes, str
[TestCase("[01:00.00]", 60000)]
[TestCase("[10:00.00]", 600000)]
[TestCase("[100:00.00]", 6000000)]
[TestCase("[12:34.567]", 754560)]
[TestCase("[0:00.00]", 0)] // prevent throw error in some invalid format.
[TestCase("[0:0.0]", 0)] // prevent throw error in some invalid format.
[TestCase("[1:00.00][1:02.00]", 60000)] // rarely to get this case, so return the first one.
Expand Down
1 change: 1 addition & 0 deletions LrcParser.Tests/Parser/Lrc/Utils/LrcTimedTextUtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void TestDecodeWithInvalidFormat(string text, string expectedText, string
[TestCase("<01:00.00>", 60000)]
[TestCase("<10:00.00>", 600000)]
[TestCase("<100:00.00>", 6000000)]
[TestCase("<12:34.567>", 754560)]
[TestCase("<0:00.00>", 0)] // prevent throw error in some invalid format.
[TestCase("<0:0.0>", 0)] // prevent throw error in some invalid format.
[TestCase("<1:00.00><1:02.00>", 60000)] // rarely to get this case, so return the first one.
Expand Down
1 change: 1 addition & 0 deletions LrcParser/Parser/Lrc/Utils/LrcStartTimeUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal static int ConvertTimeTagToMillionSecond(string timeTag)
int minutes = int.Parse(match.Groups[1].Value);
int seconds = int.Parse(match.Groups[2].Value);
int hundredths = int.Parse(match.Groups[3].Value);
hundredths = (hundredths < 100) ? hundredths : (hundredths / 10);

return minutes * 60 * 1000 + seconds * 1000 + hundredths * 10;
}
Expand Down
1 change: 1 addition & 0 deletions LrcParser/Parser/Lrc/Utils/LrcTimedTextUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ internal static int ConvertTimeTagToMillionSecond(string timeTag)
int minutes = int.Parse(match.Groups[1].Value);
int seconds = int.Parse(match.Groups[2].Value);
int hundredths = int.Parse(match.Groups[3].Value);
hundredths = (hundredths < 100) ? hundredths : (hundredths / 10);

return minutes * 60 * 1000 + seconds * 1000 + hundredths * 10;
}
Expand Down