mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-19 16:33:36 +03:00
small changes
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
1bcc62ee42
commit
fb3cefb7c8
2 changed files with 7 additions and 7 deletions
|
@ -17,7 +17,7 @@ using Remora.Discord.Extensions.Embeds;
|
|||
using Remora.Discord.Extensions.Formatting;
|
||||
using Remora.Rest.Core;
|
||||
using Remora.Results;
|
||||
using TimeSpanParser = Octobot.Parsers.TimeSpanParser;
|
||||
using Octobot.Parsers;
|
||||
|
||||
namespace Octobot.Commands;
|
||||
|
||||
|
|
|
@ -22,13 +22,14 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
|
|||
|
||||
public static Result<TimeSpan> TryParse(string timeSpanString, CancellationToken ct = default)
|
||||
{
|
||||
var timeSpan = TimeSpan.Zero;
|
||||
timeSpanString = timeSpanString.Trim();
|
||||
|
||||
if (timeSpanString.StartsWith('-'))
|
||||
{
|
||||
return TimeSpan.Zero;
|
||||
return timeSpan;
|
||||
}
|
||||
|
||||
timeSpanString = timeSpanString.Trim();
|
||||
|
||||
if (TimeSpan.TryParse(timeSpanString, DateTimeFormatInfo.InvariantInfo, out var parsedTimeSpan))
|
||||
{
|
||||
return parsedTimeSpan;
|
||||
|
@ -37,10 +38,9 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
|
|||
var matches = ParseRegex().Matches(timeSpanString);
|
||||
if (matches.Count is 0)
|
||||
{
|
||||
return TimeSpan.Zero;
|
||||
return timeSpan;
|
||||
}
|
||||
|
||||
var timeSpan = TimeSpan.Zero;
|
||||
foreach (var groups in matches.Select(match => match.Groups
|
||||
.Cast<Group>()
|
||||
.Where(g => g.Success)
|
||||
|
@ -50,7 +50,7 @@ public partial class TimeSpanParser : AbstractTypeParser<TimeSpan>
|
|||
foreach ((var key, var groupValue) in groups)
|
||||
{
|
||||
return !double.TryParse(groupValue, out var parsedGroupValue)
|
||||
? TimeSpan.Zero
|
||||
? timeSpan
|
||||
: ParseFromRegex(timeSpan, key, groupValue, parsedGroupValue);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue