Add project files.
This commit is contained in:
23
Assets/Cryville/Common/StringUtils.cs
Normal file
23
Assets/Cryville/Common/StringUtils.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Common {
|
||||
public static class StringUtils {
|
||||
public static string TrimExt(string s) {
|
||||
return s.Substring(0, s.LastIndexOf("."));
|
||||
}
|
||||
public static string ToString(this TimeSpan timeSpan, int digits) {
|
||||
var b = new StringBuilder();
|
||||
bool flag = false;
|
||||
if (timeSpan.TotalDays >= 1) {
|
||||
flag = true;
|
||||
b.Append(timeSpan.Days.ToString() + ":");
|
||||
}
|
||||
if (flag || timeSpan.TotalHours >= 1)
|
||||
b.Append((timeSpan.Hours % 24).ToString() + ":");
|
||||
b.Append((timeSpan.Minutes % 60).ToString("00") + ":");
|
||||
b.Append((timeSpan.TotalSeconds % 60).ToString("00." + new string('0', digits)));
|
||||
return b.ToString();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user