mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Use TimeSpanParser.TryParse instead of ParseTimeSpan (#257)
The ParseTimeSpan method is not needed because we no longer use the quirky (IMO) and long `Parser.TryParseAsync(from).AsTask().GetAwaiter().GetResult()` to parse TimeSpan Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
f034ede58d
commit
290449077a
1 changed files with 2 additions and 7 deletions
|
@ -11,12 +11,12 @@ public sealed class TimeSpanOption : Option<TimeSpan>
|
|||
public override TimeSpan Get(JsonNode settings)
|
||||
{
|
||||
var property = settings[Name];
|
||||
return property != null ? ParseTimeSpan(property.GetValue<string>()).Entity : DefaultValue;
|
||||
return property != null ? TimeSpanParser.TryParse(property.GetValue<string>()).Entity : DefaultValue;
|
||||
}
|
||||
|
||||
public override Result Set(JsonNode settings, string from)
|
||||
{
|
||||
if (!ParseTimeSpan(from).IsDefined(out var span))
|
||||
if (!TimeSpanParser.TryParse(from).IsDefined(out var span))
|
||||
{
|
||||
return new ArgumentInvalidError(nameof(from), Messages.InvalidSettingValue);
|
||||
}
|
||||
|
@ -24,9 +24,4 @@ public sealed class TimeSpanOption : Option<TimeSpan>
|
|||
settings[Name] = span.ToString();
|
||||
return Result.FromSuccess();
|
||||
}
|
||||
|
||||
private static Result<TimeSpan> ParseTimeSpan(string from)
|
||||
{
|
||||
return TimeSpanParser.TryParse(from);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue