Skip to content

Commit 65882e4

Browse files
refactor: Simplify conditional logic in BuildRelative method of TimeAgoTagHelper
1 parent 420a098 commit 65882e4

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/XtremeIdiots.Portal.Web/Helpers/TimeAgoTagHelper.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ private static string BuildRelative(DateTime dateTimeUtc)
4848
var minutes = span.TotalMinutes;
4949
var hours = span.TotalHours;
5050
var days = span.TotalDays;
51-
if (seconds < 45)
52-
return future ? "in a few seconds" : "just now";
53-
if (seconds < 90)
54-
return future ? "in a minute" : "a minute ago";
55-
if (minutes < 45)
56-
return future ? $"in {Math.Round(minutes)} minutes" : $"{Math.Round(minutes)} minutes ago";
57-
if (minutes < 90)
58-
return future ? "in an hour" : "an hour ago";
59-
return hours < 24
51+
return seconds < 45
52+
? future ? "in a few seconds" : "just now"
53+
: seconds < 90
54+
? future ? "in a minute" : "a minute ago"
55+
: minutes < 45
56+
? future ? $"in {Math.Round(minutes)} minutes" : $"{Math.Round(minutes)} minutes ago"
57+
: minutes < 90
58+
? future ? "in an hour" : "an hour ago"
59+
: hours < 24
6060
? future ? $"in {Math.Round(hours)} hours" : $"{Math.Round(hours)} hours ago"
6161
: hours < 42
6262
? future ? "in a day" : "a day ago"

0 commit comments

Comments
 (0)