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:
Macintxsh 2024-01-28 21:36:29 +03:00 committed by GitHub
parent f034ede58d
commit 290449077a
Signed by: GitHub
GPG key ID: B5690EEEBB952194

View file

@ -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);
}
}