diff --git a/src/Nonemm.Spotting/SpotDescription.cs b/src/Nonemm.Spotting/SpotDescription.cs index 6b91edd..32dcce3 100644 --- a/src/Nonemm.Spotting/SpotDescription.cs +++ b/src/Nonemm.Spotting/SpotDescription.cs @@ -1,11 +1,12 @@ using System.Globalization; +using System.Text.RegularExpressions; namespace Nonemm.Spotting; /// What the bandmap shows when the pointer rests on a spot: the frequency, /// who spotted it and how long ago, and the comment if it says more than the /// sideband. -public static class SpotDescription +public static partial class SpotDescription { public static string Of(Spot spot, DateTime? nowUtc = null) { @@ -19,6 +20,9 @@ public static class SpotDescription return comment.Length > 0 ? $"{first}\n{comment}" : first; } + [GeneratedRegex(@"\s*\b\d{4}Z$", RegexOptions.IgnoreCase)] + private static partial Regex TrailingTime(); + private static string Age(TimeSpan span) { int minutes = Math.Max(0, (int)span.TotalMinutes); @@ -34,7 +38,9 @@ public static class SpotDescription private static string Comment(string text) { string clean = new([.. text.Where(c => !char.IsControl(c))]); - clean = clean.Trim(); + // the cluster ends its line with the time of the spot, which the age + // already says + clean = TrailingTime().Replace(clean, "").Trim(); return clean.ToUpperInvariant() is "LSB" or "USB" or "SSB" ? "" : clean; } }