27 lines
647 B
C#
27 lines
647 B
C#
namespace Utils
|
|
{
|
|
public static class Time
|
|
{
|
|
public static void Sleep(TimeSpan span)
|
|
{
|
|
Thread.Sleep(span);
|
|
}
|
|
|
|
public static T Wait<T>(Task<T> task)
|
|
{
|
|
task.Wait();
|
|
return task.Result;
|
|
}
|
|
|
|
public static string FormatDuration(TimeSpan d)
|
|
{
|
|
var result = "";
|
|
if (d.Days > 0) result += $"{d.Days} days, ";
|
|
if (d.Hours > 0) result += $"{d.Hours} hours, ";
|
|
if (d.Minutes > 0) result += $"{d.Minutes} mins, ";
|
|
result += $"{d.Seconds} secs";
|
|
return result;
|
|
}
|
|
}
|
|
}
|