1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

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

View File

@ -58,6 +58,9 @@ namespace osu.Game.Extensions
/// <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;