Skip to content

Commit

Permalink
fix: Humanreadable format with day support
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimple committed Dec 18, 2023
1 parent 859ad45 commit fd5f11b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CFLookup/SharedMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static async Task<List<Category>> GetCategoryInfo(IDatabaseAsync _redis,
FileIds = new List<int> { fileId }
});

if(file.Data.Count == 0)
if (file.Data.Count == 0)
return (null, null, null);

var mod = await _cfApiClient.GetModAsync(file.Data[0].ModId);
Expand Down Expand Up @@ -359,7 +359,8 @@ public static string GetProjectNameFromFile(string url)

public static string ToHumanReadableFormat(this TimeSpan timeSpan)
{
return timeSpan.TotalSeconds <= 0 ? "0 seconds" : string.Format("{0}{1}{2}",
return timeSpan.TotalSeconds <= 0 ? "0 seconds" : string.Format("{0}{1}{2}{3}",
timeSpan.Days > 0 ? string.Format($"{timeSpan.Days:n0} day{{0}}, ", timeSpan.Days != 1 ? "s" : string.Empty) : string.Empty,
timeSpan.Hours > 0 ? string.Format($"{timeSpan.Hours:n0} hour{{0}}, ", timeSpan.Hours != 1 ? "s" : string.Empty) : string.Empty,
timeSpan.Minutes > 0 ? string.Format($"{timeSpan.Minutes:n0} minute{{0}}, ", timeSpan.Minutes != 1 ? "s" : string.Empty) : string.Empty,
timeSpan.Seconds > 0 ? string.Format($"{timeSpan.Seconds:n0} second{{0}}", timeSpan.Seconds != 1 ? "s" : string.Empty) : string.Empty
Expand Down

0 comments on commit fd5f11b

Please sign in to comment.