mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 05:22:54 +08:00
Add slash and dot as valid separators in dates.
This commit is contained in:
parent
2369e98cfc
commit
b58576f31b
@ -633,23 +633,23 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
private static readonly object[] ranked_date_valid_test_cases =
|
private static readonly object[] ranked_date_valid_test_cases =
|
||||||
{
|
{
|
||||||
new object[] { "ranked<2012", dateTimeOffsetFromDateOnly(2012, 1, 1), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<2012", dateTimeOffsetFromDateOnly(2012, 1, 1), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
new object[] { "ranked<2012-03", dateTimeOffsetFromDateOnly(2012, 3, 1), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<2012.03", dateTimeOffsetFromDateOnly(2012, 3, 1), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
new object[] { "ranked<2012-03-05", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<2012/03/05", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
new object[] { "ranked<2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
|
|
||||||
new object[] { "ranked<=2012", dateTimeOffsetFromDateOnly(2013, 1, 1), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<=2012", dateTimeOffsetFromDateOnly(2013, 1, 1), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
new object[] { "ranked<=2012-03", dateTimeOffsetFromDateOnly(2012, 4, 1), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<=2012.03", dateTimeOffsetFromDateOnly(2012, 4, 1), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
new object[] { "ranked<=2012-03-05", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<=2012/03/05", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
new object[] { "ranked<=2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Max },
|
new object[] { "ranked<=2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Max },
|
||||||
|
|
||||||
new object[] { "ranked>2012", dateTimeOffsetFromDateOnly(2013, 1, 1), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>2012", dateTimeOffsetFromDateOnly(2013, 1, 1), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
new object[] { "ranked>2012-03", dateTimeOffsetFromDateOnly(2012, 4, 1), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>2012.03", dateTimeOffsetFromDateOnly(2012, 4, 1), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
new object[] { "ranked>2012-03-05", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>2012/03/05", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
new object[] { "ranked>2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 6), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
|
|
||||||
new object[] { "ranked>=2012", dateTimeOffsetFromDateOnly(2012, 1, 1), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>=2012", dateTimeOffsetFromDateOnly(2012, 1, 1), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
new object[] { "ranked>=2012-03", dateTimeOffsetFromDateOnly(2012, 3, 1), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>=2012.03", dateTimeOffsetFromDateOnly(2012, 3, 1), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
new object[] { "ranked>=2012-03-05", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>=2012/03/05", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
new object[] { "ranked>=2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked>=2012-3-5", dateTimeOffsetFromDateOnly(2012, 3, 5), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
|
|
||||||
new object[] { "ranked=2012", dateTimeOffsetFromDateOnly(2012, 1, 1), (FilterCriteria x) => x.DateRanked.Min },
|
new object[] { "ranked=2012", dateTimeOffsetFromDateOnly(2012, 1, 1), (FilterCriteria x) => x.DateRanked.Min },
|
||||||
@ -675,7 +675,6 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
new object[] { "ranked<0" },
|
new object[] { "ranked<0" },
|
||||||
new object[] { "ranked=99999" },
|
new object[] { "ranked=99999" },
|
||||||
new object[] { "ranked>=2012-03-05-04" },
|
new object[] { "ranked>=2012-03-05-04" },
|
||||||
new object[] { "ranked>2007.5" },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -690,14 +689,14 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
private static readonly object[] submitted_date_test_cases =
|
private static readonly object[] submitted_date_test_cases =
|
||||||
{
|
{
|
||||||
new object[] { "submitted<2012", true },
|
new object[] { "submitted<2012", true },
|
||||||
new object[] { "submitted<2012-03", true },
|
new object[] { "submitted<2012.03", true },
|
||||||
new object[] { "submitted<2012-03-05", true },
|
new object[] { "submitted<2012/03/05", true },
|
||||||
new object[] { "submitted<2012-3-5", true },
|
new object[] { "submitted<2012-3-5", true },
|
||||||
|
|
||||||
new object[] { "submitted<0", false },
|
new object[] { "submitted<0", false },
|
||||||
new object[] { "submitted=99999", false },
|
new object[] { "submitted=99999", false },
|
||||||
new object[] { "submitted>=2012-03-05-04", false },
|
new object[] { "submitted>=2012-03-05-04", false },
|
||||||
new object[] { "submitted>2007.5", false },
|
new object[] { "submitted>=2012/03.05-04", false },
|
||||||
};
|
};
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -609,7 +609,8 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses a string containing a ranked or submitted date filter.
|
/// Parses a string containing a ranked or submitted date filter.
|
||||||
/// Returns a boolean depending on whether parsing was successful or not.
|
/// Returns a boolean depending on whether parsing was successful or not.
|
||||||
/// Accepted dates are in the formats `yyyy`, `yyyy-mm` and `yyyy-mm-dd`. Leading zeros are accepted.
|
/// Accepted dates are in the formats `yyyy`, `yyyy-mm` and `yyyy-mm-dd`.
|
||||||
|
/// Leading zeros are accepted. Numbers can be separated by `-`, `/`, or `.`
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dateRange">The <see cref="FilterCriteria.OptionalRange{DateTimeOffset}"/> to store the parsed data into, if successful.</param>
|
/// <param name="dateRange">The <see cref="FilterCriteria.OptionalRange{DateTimeOffset}"/> to store the parsed data into, if successful.</param>
|
||||||
/// <param name="op">The operator of the filtering query</param>
|
/// <param name="op">The operator of the filtering query</param>
|
||||||
@ -618,7 +619,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
GroupCollection? match = null;
|
GroupCollection? match = null;
|
||||||
|
|
||||||
match ??= tryMatchRegex(val, @"^(?<year>\d+)(-(?<month>\d+)(-(?<day>\d+))?)?$");
|
match ??= tryMatchRegex(val, @"^(?<year>\d+)((-|/|\.)(?<month>\d+)((-|/|\.)(?<day>\d+))?)?$");
|
||||||
|
|
||||||
if (match == null)
|
if (match == null)
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user