This commit is contained in:
Nikolaj Olsson 2017-02-23 10:06:50 +01:00
parent 246ae3f88b
commit da4e4dc2b8
2 changed files with 37 additions and 5 deletions

View File

@ -214,12 +214,11 @@ namespace Nikse.SubtitleEdit.Core
{
string s = ToHHMMSSFF();
int j = 0;
if (s.StartsWith("0:00:", StringComparison.Ordinal))
j = 5;
if (s.StartsWith("00:", StringComparison.Ordinal))
j += 3;
if (s.StartsWith("00:", StringComparison.Ordinal))
int len = s.Length;
while (j + 6 < len && s[j] == '0' && s[j + 1] == '0' && s[j + 2] == ':')
{
j += 3;
}
return j > 0 ? s.Substring(j) : s;
}

View File

@ -132,5 +132,38 @@ namespace Test.Logic
Assert.IsTrue(Math.Abs(tc.TotalMilliseconds - (tc.TotalSeconds * 1000.0)) < 0.001);
}
[TestMethod]
public void ToShortStringHhmmssff1()
{
Configuration.Settings.General.CurrentFrameRate = 25;
var res = new TimeCode(1, 2, 3, 0).ToShortStringHHMMSSFF();
Assert.AreEqual("01:02:03:00", res);
}
[TestMethod]
public void ToShortStringHhmmssff2()
{
Configuration.Settings.General.CurrentFrameRate = 25;
var res = new TimeCode(0, 2, 3, 0).ToShortStringHHMMSSFF();
Assert.AreEqual(res, "02:03:00", res);
}
[TestMethod]
public void ToShortStringHhmmssff3()
{
Configuration.Settings.General.CurrentFrameRate = 25;
var res = new TimeCode(0, 0, 3, 0).ToShortStringHHMMSSFF();
Assert.AreEqual("03:00", res);
}
[TestMethod]
public void ToShortStringHhmmssff4()
{
Configuration.Settings.General.CurrentFrameRate = 25;
var res = new TimeCode(0, 0, 0, 0).ToShortStringHHMMSSFF();
Assert.AreEqual("00:00", res);
}
}
}