1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:33:20 +08:00

Enforce integer value before y and M

Change impacted Tests
This commit is contained in:
Elvendir 2023-04-05 22:12:15 +02:00
parent c2f225f025
commit 928145cdeb
2 changed files with 13 additions and 7 deletions

View File

@ -325,8 +325,8 @@ namespace osu.Game.Tests.NonVisual.Filtering
new object[] { "48h120s" },
new object[] { "10y24M" },
new object[] { "10y60d120s" },
new object[] { "0.1y0.1M2d" },
new object[] { "0.99y0.99M2d" }
new object[] { "0y0M2d" },
new object[] { "1y1M2d" }
};
[Test]
@ -348,7 +348,9 @@ namespace osu.Game.Tests.NonVisual.Filtering
new object[] { "7d7y" },
new object[] { "0:3:6" },
new object[] { "0:3:" },
new object[] { "\"three days\"" }
new object[] { "\"three days\"" },
new object[] { "0.1y0.1M2d" },
new object[] { "0.99y0.99M2d" }
};
[Test]

View File

@ -419,13 +419,17 @@ namespace osu.Game.Screens.Select
break;
case "months":
dateTimeOffset = dateTimeOffset.AddMonths(-(int)Math.Floor(length));
dateTimeOffset = dateTimeOffset.AddDays(-30 * (length - Math.Floor(length)));
if (match[key].Value.Contains('.'))
return false;
dateTimeOffset = dateTimeOffset.AddMonths(-(int)length);
break;
case "years":
dateTimeOffset = dateTimeOffset.AddYears(-(int)Math.Floor(length));
dateTimeOffset = dateTimeOffset.AddDays(-365 * (length - Math.Floor(length)));
if (match[key].Value.Contains('.'))
return false;
dateTimeOffset = dateTimeOffset.AddYears(-(int)length);
break;
}
}