From bdb663fd95d525ddd1d46b42583e525d70a5df51 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 10 Aug 2022 09:32:15 +0200 Subject: [PATCH] Permit use of decimal comma --- Logic/Support/Formatting.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Logic/Support/Formatting.cs b/Logic/Support/Formatting.cs index 54100f39..c8071f26 100644 --- a/Logic/Support/Formatting.cs +++ b/Logic/Support/Formatting.cs @@ -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);