You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
548 B
C#
24 lines
548 B
C#
using System;
|
|
|
|
namespace Expedience.Web.Extensions;
|
|
|
|
public static class Extensions
|
|
{
|
|
public static string Format(this TimeSpan? timeSpan)
|
|
{
|
|
if (timeSpan is null)
|
|
return "";
|
|
var roundedTimeSpan = new TimeSpan(timeSpan.Value.Days, timeSpan.Value.Hours,
|
|
timeSpan.Value.Minutes, timeSpan.Value.Seconds,
|
|
RoundToNearestTen(timeSpan.Value.Milliseconds));
|
|
|
|
return roundedTimeSpan.ToString("hh\\:mm\\:ss\\.ff");
|
|
}
|
|
|
|
static int RoundToNearestTen(int num)
|
|
{
|
|
int rem = num % 10;
|
|
return rem >= 5 ? (num - rem + 10) : (num - rem);
|
|
}
|
|
}
|