diff --git a/Source/Application/Kysect.Shreks.Application.Commands/Commands/UpdateCommand.cs b/Source/Application/Kysect.Shreks.Application.Commands/Commands/UpdateCommand.cs index 29212de25..e147852cb 100644 --- a/Source/Application/Kysect.Shreks.Application.Commands/Commands/UpdateCommand.cs +++ b/Source/Application/Kysect.Shreks.Application.Commands/Commands/UpdateCommand.cs @@ -3,7 +3,9 @@ using Kysect.Shreks.Common.Exceptions; using Kysect.Shreks.Core.Models; using Kysect.Shreks.Core.Submissions; +using Kysect.Shreks.Core.Tools; using Microsoft.Extensions.Logging; +using System.Globalization; namespace Kysect.Shreks.Application.Commands.Commands; @@ -32,10 +34,7 @@ public UpdateCommand(int submissionCode, double? ratingPercent, double? extraPoi public DateOnly GetDate() { - if (!DateOnly.TryParse(DateStr, out DateOnly date)) - throw new InvalidUserInputException($"Cannot parse input date ({DateStr} as date. Ensure that you use correct format."); - - return date; + return RuCultureDate.Parse(DateStr); } public async Task ExecuteAsync(SubmissionContext context, ILogger logger, CancellationToken cancellationToken) diff --git a/Source/Domain/Kysect.Shreks.Core/Tools/RuCultureDate.cs b/Source/Domain/Kysect.Shreks.Core/Tools/RuCultureDate.cs new file mode 100644 index 000000000..90c6c3ccd --- /dev/null +++ b/Source/Domain/Kysect.Shreks.Core/Tools/RuCultureDate.cs @@ -0,0 +1,15 @@ +using Kysect.Shreks.Common.Exceptions; +using System.Globalization; + +namespace Kysect.Shreks.Core.Tools; + +public class RuCultureDate +{ + public static DateOnly Parse(string? value) + { + if (!DateOnly.TryParse(value, CultureInfo.GetCultureInfo("ru-Ru"), DateTimeStyles.None, out DateOnly date)) + throw new InvalidUserInputException($"Cannot parse input date ({value} as date. Ensure that you use correct format."); + + return date; + } +} \ No newline at end of file