Added GetHumanReadable for TimeSpan & FirstLetterToUpper

This commit is contained in:
XorogVEVO 2022-02-06 10:59:19 +01:00
parent fa7289365b
commit 579e7b93c0

View file

@ -402,6 +402,15 @@ public static class UniversalExtensions
public static string GetHumanReadable(this long seconds, TimeFormat timeFormat = TimeFormat.DAYS) => public static string GetHumanReadable(this long seconds, TimeFormat timeFormat = TimeFormat.DAYS) =>
TimeSpan.FromSeconds(seconds).GetTimeFormat(timeFormat); TimeSpan.FromSeconds(seconds).GetTimeFormat(timeFormat);
/// <summary>
/// <inheritdoc cref="UniversalExtensions.GetHumanReadable(int, TimeFormat)"/>
/// </summary>
/// <param name="timeSpan"></param>
/// <param name="timeFormat"></param>
/// <returns></returns>
public static string GetHumanReadable(this TimeSpan timeSpan, TimeFormat timeFormat = TimeFormat.DAYS) =>
timeSpan.GetTimeFormat(timeFormat);
/// <summary> /// <summary>
@ -489,4 +498,9 @@ public static class StringExt
using SHA256 _SHA256 = SHA256.Create(); using SHA256 _SHA256 = SHA256.Create();
return BitConverter.ToString(_SHA256.ComputeHash(Encoding.ASCII.GetBytes(str))).Replace("-", "").ToLowerInvariant(); return BitConverter.ToString(_SHA256.ComputeHash(Encoding.ASCII.GetBytes(str))).Replace("-", "").ToLowerInvariant();
} }
public static string FirstLetterToUpper(this string str)
{
return $"{str.First().ToString().ToUpper()}{str.Remove(0, 1)}";
}
} }