Skip to content

Commit

Permalink
Fix float handling
Browse files Browse the repository at this point in the history
  • Loading branch information
timia2109 committed Apr 28, 2024
1 parent 1c32f6c commit c1001ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion DisplayUtil/Template/UtilTemplateExtender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1001ce

Please sign in to comment.