-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensions.cs
More file actions
24 lines (20 loc) · 856 Bytes
/
Extensions.cs
File metadata and controls
24 lines (20 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
namespace CryCompressor
{
internal static class Extensions
{
internal static string ToTimeString(this double timeMilliseconds)
{
if (timeMilliseconds < 1000) return $"{Math.Round(timeMilliseconds, 2)}ms";
else if (timeMilliseconds < 1000 * 60) return $"{Math.Round((timeMilliseconds / 1000.0), 2)}sec";
else if (timeMilliseconds < 1000 * 60 * 60) return $"{Math.Round(((timeMilliseconds / 1000.0) / 60), 2)}min";
else return $"{Math.Round((((timeMilliseconds / 1000.0) / 60) / 60), 2)}h";
}
internal static string GetExtensionWithoutDot(this string extension)
{
if (string.IsNullOrEmpty(extension)) return extension;
if (extension.StartsWith('.')) return extension[1..];
return extension;
}
}
}