mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 05:32:54 +08:00
changed regex match to be inline with standard
This commit is contained in:
parent
6dead81d21
commit
4b053b4785
@ -322,8 +322,6 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
private static readonly object[] correct_date_query_examples =
|
||||
{
|
||||
new object[] { "600" },
|
||||
new object[] { "120:120" },
|
||||
new object[] { "48:0:0" },
|
||||
new object[] { "0.5s" },
|
||||
new object[] { "120m" },
|
||||
new object[] { "48h120s" },
|
||||
@ -350,6 +348,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
new object[] { "5s6m" },
|
||||
new object[] { "7d7y" },
|
||||
new object[] { ":0" },
|
||||
new object[] { "0:3:6" },
|
||||
new object[] { "0:3:" },
|
||||
new object[] { "\"three days\"" }
|
||||
};
|
||||
|
@ -378,9 +378,8 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
GroupCollection? match = null;
|
||||
|
||||
match ??= tryMatchRegex(val, @"^((?<hours>\d+):)?(?<minutes>\d+):(?<seconds>\d+)$");
|
||||
match ??= tryMatchRegex(val, @"^((?<years>\d+(\.\d+)?)y)?((?<months>\d+(\.\d+)?)M)?((?<days>\d+(\.\d+)?)d)?((?<hours>\d+(\.\d+)?)h)?((?<minutes>\d+(\.\d+)?)m)?((?<seconds>\d+(\.\d+)?)s)?$");
|
||||
match ??= tryMatchRegex(val, @"^(?<seconds>\d+(\.\d+)?)$");
|
||||
match ??= tryMatchRegex(val, @"^(?<days>\d+(\.\d+)?)$");
|
||||
|
||||
if (match == null)
|
||||
return false;
|
||||
@ -417,11 +416,13 @@ namespace osu.Game.Screens.Select
|
||||
break;
|
||||
|
||||
case "months":
|
||||
dateTimeOffset = dateTimeOffset.AddMonths(-(int)Math.Round(length));
|
||||
dateTimeOffset = dateTimeOffset.AddMonths(-(int)Math.Floor(length));
|
||||
dateTimeOffset = dateTimeOffset.AddDays(-30 * (length - Math.Floor(length)));
|
||||
break;
|
||||
|
||||
case "years":
|
||||
dateTimeOffset = dateTimeOffset.AddYears(-(int)Math.Round(length));
|
||||
dateTimeOffset = dateTimeOffset.AddYears(-(int)Math.Floor(length));
|
||||
dateTimeOffset = dateTimeOffset.AddDays(-365 * (length - Math.Floor(length)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user