Permit use of decimal comma

This commit is contained in:
Rick Falkvinge
2022-08-10 09:32:15 +02:00
parent dd666cd950
commit bdb663fd95
+11
View File
@@ -171,6 +171,17 @@ namespace Swarmops.Logic.Support
// Try invariant (US) culture as fallback
// If decimal comma in decimal point position, replace with decimal point
if (input.Length > 3)
{
if (input[input.Length - 3] == ',')
{
input = input.Substring(0, input.Length - 3) + "." + input.Substring(input.Length - 2, 2);
}
}
success = Double.TryParse(input,
NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint,
CultureInfo.InvariantCulture, out outputHolder);