forked from TeamInklings/Octobot
Use custom TimeSpanParser (#223)
Closes #154 --------- Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
894e819865
commit
e01fde83c6
10 changed files with 183 additions and 16 deletions
|
@ -1,13 +1,11 @@
|
|||
using System.Text.Json.Nodes;
|
||||
using Remora.Commands.Parsers;
|
||||
using Octobot.Parsers;
|
||||
using Remora.Results;
|
||||
|
||||
namespace Octobot.Data.Options;
|
||||
|
||||
public sealed class TimeSpanOption : Option<TimeSpan>
|
||||
{
|
||||
private static readonly TimeSpanParser Parser = new();
|
||||
|
||||
public TimeSpanOption(string name, TimeSpan defaultValue) : base(name, defaultValue) { }
|
||||
|
||||
public override TimeSpan Get(JsonNode settings)
|
||||
|
@ -29,6 +27,6 @@ public sealed class TimeSpanOption : Option<TimeSpan>
|
|||
|
||||
private static Result<TimeSpan> ParseTimeSpan(string from)
|
||||
{
|
||||
return Parser.TryParseAsync(from).AsTask().GetAwaiter().GetResult();
|
||||
return TimeSpanParser.TryParse(from);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue