Files
WowUp/WowUp.Common/Extensions/IntExtensions.cs
jliddev e9499f15b0 New TukUI Api
Support higher download number format.
Lower cache time to 10 minutes from 60 minutes.
2020-08-31 13:52:12 -05:00

29 lines
754 B
C#

namespace WowUp.Common.Extensions
{
public static class IntExtensions
{
public static string FormatDownloadCount(this long downloadCount)
{
var suffix = string.Empty;
var value = (double)downloadCount;
if (downloadCount >= 1000000000)
{
suffix = "billion";
value /= 1000000000.0;
}
else if (downloadCount >= 1000000)
{
suffix = "million";
value /= 1000000.0;
}
else if (downloadCount >= 1000)
{
suffix = "thousand";
value /= 1000.0;
}
return $"{value:0.0} {suffix}";
}
}
}