Update Cryville.Common.

This commit is contained in:
2022-10-14 23:32:43 +08:00
parent d3cac8a28d
commit c8eee7ab3f
18 changed files with 497 additions and 47 deletions

View File

@@ -2,10 +2,24 @@
using System.Text;
namespace Cryville.Common {
/// <summary>
/// Provides a set of <see langword="static" /> methods related to string operations.
/// </summary>
public static class StringUtils {
/// <summary>
/// Removes the extension in a file name or file path.
/// </summary>
/// <param name="s">The file name or file path.</param>
/// <returns>The file name or file path with the extension removed.</returns>
public static string TrimExt(string s) {
return s.Substring(0, s.LastIndexOf("."));
}
/// <summary>
/// Converts the value of a <see cref="TimeSpan" /> to a human-readable string.
/// </summary>
/// <param name="timeSpan">The time span.</param>
/// <param name="digits">The digit count for seconds.</param>
/// <returns>A human-readable string representing the time span.</returns>
public static string ToString(this TimeSpan timeSpan, int digits) {
var b = new StringBuilder();
bool flag = false;