From c1001ce1a45154ef981667af296d87aa57f8f109 Mon Sep 17 00:00:00 2001 From: Tim Ittermann Date: Sun, 28 Apr 2024 16:17:59 +0200 Subject: [PATCH] Fix float handling --- DisplayUtil/Template/UtilTemplateExtender.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DisplayUtil/Template/UtilTemplateExtender.cs b/DisplayUtil/Template/UtilTemplateExtender.cs index a665bb5..2eb2559 100644 --- a/DisplayUtil/Template/UtilTemplateExtender.cs +++ b/DisplayUtil/Template/UtilTemplateExtender.cs @@ -18,7 +18,11 @@ public void Enrich(ScriptObject scriptObject, EnrichScope scope) public static float ToFloat(string? content) { if (content == null) return 0; - return float.Parse(content, CultureInfo.InvariantCulture); + if (float.TryParse(content, CultureInfo.InvariantCulture, out var value)) + { + return value; + } + return 0; } public static string TimespanToString(TimeSpan timeSpan, string format)