-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExtensions.cs
More file actions
19 lines (18 loc) · 683 Bytes
/
Extensions.cs
File metadata and controls
19 lines (18 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System;
namespace AusStockChecker
{
public static class TimeSpanExtensions
{
public static string ToShortTime(this TimeSpan timeSpan)
{
if (timeSpan.TotalDays >= 1)
return $"{timeSpan.Days}d{timeSpan.Hours:00}h{timeSpan.Minutes:00}m{timeSpan.Seconds:00}s";
else if (timeSpan.TotalHours >= 1)
return $"{timeSpan.Hours:00}h{timeSpan.Minutes:00}m{timeSpan.Seconds:00}s";
else if (timeSpan.TotalMinutes >= 1)
return $"{timeSpan.Minutes:00}m{timeSpan.Seconds:00}s";
else
return $"{timeSpan.Seconds:00}s";
}
}
}