1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 16:33:36 +03:00

Revert "small changes"

This reverts commit fb3cefb7c8.
This commit is contained in:
Macintxsh 2023-12-28 13:53:51 +03:00
parent fb3cefb7c8
commit bfd767cf0a
Signed by: mctaylors
GPG key ID: 7181BEBE676903C1
2 changed files with 7 additions and 7 deletions

View file

@ -17,7 +17,7 @@ using Remora.Discord.Extensions.Embeds;
using Remora.Discord.Extensions.Formatting; using Remora.Discord.Extensions.Formatting;
using Remora.Rest.Core; using Remora.Rest.Core;
using Remora.Results; using Remora.Results;
using Octobot.Parsers; using TimeSpanParser = Octobot.Parsers.TimeSpanParser;
namespace Octobot.Commands; namespace Octobot.Commands;

View file

@ -22,14 +22,13 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
public static Result<TimeSpan> TryParse(string timeSpanString, CancellationToken ct = default) public static Result<TimeSpan> TryParse(string timeSpanString, CancellationToken ct = default)
{ {
var timeSpan = TimeSpan.Zero;
timeSpanString = timeSpanString.Trim();
if (timeSpanString.StartsWith('-')) if (timeSpanString.StartsWith('-'))
{ {
return timeSpan; return TimeSpan.Zero;
} }
timeSpanString = timeSpanString.Trim();
if (TimeSpan.TryParse(timeSpanString, DateTimeFormatInfo.InvariantInfo, out var parsedTimeSpan)) if (TimeSpan.TryParse(timeSpanString, DateTimeFormatInfo.InvariantInfo, out var parsedTimeSpan))
{ {
return parsedTimeSpan; return parsedTimeSpan;
@ -38,9 +37,10 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
var matches = ParseRegex().Matches(timeSpanString); var matches = ParseRegex().Matches(timeSpanString);
if (matches.Count is 0) if (matches.Count is 0)
{ {
return timeSpan; return TimeSpan.Zero;
} }
var timeSpan = TimeSpan.Zero;
foreach (var groups in matches.Select(match => match.Groups foreach (var groups in matches.Select(match => match.Groups
.Cast<Group>() .Cast<Group>()
.Where(g => g.Success) .Where(g => g.Success)
@ -50,7 +50,7 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
foreach ((var key, var groupValue) in groups) foreach ((var key, var groupValue) in groups)
{ {
return !double.TryParse(groupValue, out var parsedGroupValue) return !double.TryParse(groupValue, out var parsedGroupValue)
? timeSpan ? TimeSpan.Zero
: ParseFromRegex(timeSpan, key, groupValue, parsedGroupValue); : ParseFromRegex(timeSpan, key, groupValue, parsedGroupValue);
} }
} }