[frontend/mfm] Use double.TryParse instead of try/catch

This commit is contained in:
pancakes 2025-01-06 11:45:32 +10:00 committed by Iceshrimp development
parent dd768242e1
commit 2b124f9e34

View file

@ -536,14 +536,7 @@ public static partial class MfmRenderer
if (childText == null) return el;
double timestamp;
try
{
timestamp = double.Parse(childText);
}
catch
{
return el;
}
if (!double.TryParse(childText, out timestamp)) return el;
var date = DateTime.UnixEpoch.AddSeconds(timestamp);
el.SetAttribute("datetime", date.ToLocalTime().ToString("O"));