Gracefully handle undefined `DateTimeOffset` values

Only seems to happen in tests, but best to safeguard against this
regardless.
This commit is contained in:
Dean Herbert 2022-02-21 16:35:39 +09:00
parent 3d0caa44c8
commit 2f6e65a9a2
1 changed files with 3 additions and 0 deletions

View File

@ -58,6 +58,9 @@ public static LocalisableString ToFormattedDuration(this TimeSpan timeSpan)
/// <returns>A short relative string representing the input time.</returns>
public static string ToShortRelativeTime(this DateTimeOffset time, TimeSpan lowerCutoff)
{
if (time == default)
return "-";
var now = DateTime.Now;
var difference = now - time;