Skip to content

Commit

Permalink
bruh
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Sep 21, 2024
1 parent 16c6e55 commit e6d244b
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,33 @@ public static class StringExtensions
public static int ToMilliseconds(this string src)
{
int result;
string[] spilt = src.Split(".");

if (spilt.Length < 3)
{
// ???
Logging.Log($"给定的时间不正确:{src}");
return int.MaxValue;
}

string formatString = "";

for (int i = 0; i < spilt[0].Length; i++)
formatString += "m";

formatString += @"\.";

for (int i = 0; i < spilt[1].Length; i++)
formatString += "s";

formatString += @"\.";

for (int i = 0; i < spilt[2].Length; i++)
formatString += "f";

try
{
var timeSpan = TimeSpan.ParseExact($"{src}", @"mm\.ss\.fff", new DateTimeFormatInfo());
var timeSpan = TimeSpan.ParseExact($"{src}", formatString, new DateTimeFormatInfo());
result = (int)timeSpan.TotalMilliseconds;
}
catch (Exception e)
Expand Down

0 comments on commit e6d244b

Please sign in to comment.