1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Abandon date filter if no meaningful time bound found during parsing

This commit is contained in:
Bartłomiej Dach 2024-02-14 15:56:32 +01:00
parent d7dfc8b88a
commit c24328dda3
No known key found for this signature in database

View File

@ -394,7 +394,8 @@ namespace osu.Game.Screens.Select
if (match == null) if (match == null)
return false; return false;
DateTimeOffset dateTimeOffset = DateTimeOffset.Now; DateTimeOffset? dateTimeOffset = null;
DateTimeOffset now = DateTimeOffset.Now;
try try
{ {
@ -410,27 +411,27 @@ namespace osu.Game.Screens.Select
switch (key) switch (key)
{ {
case "seconds": case "seconds":
dateTimeOffset = dateTimeOffset.AddSeconds(-length); dateTimeOffset = (dateTimeOffset ?? now).AddSeconds(-length);
break; break;
case "minutes": case "minutes":
dateTimeOffset = dateTimeOffset.AddMinutes(-length); dateTimeOffset = (dateTimeOffset ?? now).AddMinutes(-length);
break; break;
case "hours": case "hours":
dateTimeOffset = dateTimeOffset.AddHours(-length); dateTimeOffset = (dateTimeOffset ?? now).AddHours(-length);
break; break;
case "days": case "days":
dateTimeOffset = dateTimeOffset.AddDays(-length); dateTimeOffset = (dateTimeOffset ?? now).AddDays(-length);
break; break;
case "months": case "months":
dateTimeOffset = dateTimeOffset.AddMonths(-(int)length); dateTimeOffset = (dateTimeOffset ?? now).AddMonths(-(int)length);
break; break;
case "years": case "years":
dateTimeOffset = dateTimeOffset.AddYears(-(int)length); dateTimeOffset = (dateTimeOffset ?? now).AddYears(-(int)length);
break; break;
} }
} }
@ -438,11 +439,13 @@ namespace osu.Game.Screens.Select
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
dateTimeOffset = DateTimeOffset.MinValue; dateTimeOffset = DateTimeOffset.MinValue.AddMilliseconds(1);
dateTimeOffset = dateTimeOffset.AddMilliseconds(1);
} }
return tryUpdateCriteriaRange(ref dateRange, reverseInequalityOperator(op), dateTimeOffset); if (!dateTimeOffset.HasValue)
return false;
return tryUpdateCriteriaRange(ref dateRange, reverseInequalityOperator(op), dateTimeOffset.Value);
} }
// Function to reverse an Operator // Function to reverse an Operator