Leave the cluster's time out of the bandmap hover comment
A cluster line ends with the time of the spot, which the age on the first line already says. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Nonemm.Spotting;
|
namespace Nonemm.Spotting;
|
||||||
|
|
||||||
/// What the bandmap shows when the pointer rests on a spot: the frequency,
|
/// 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
|
/// who spotted it and how long ago, and the comment if it says more than the
|
||||||
/// sideband.
|
/// sideband.
|
||||||
public static class SpotDescription
|
public static partial class SpotDescription
|
||||||
{
|
{
|
||||||
public static string Of(Spot spot, DateTime? nowUtc = null)
|
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;
|
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)
|
private static string Age(TimeSpan span)
|
||||||
{
|
{
|
||||||
int minutes = Math.Max(0, (int)span.TotalMinutes);
|
int minutes = Math.Max(0, (int)span.TotalMinutes);
|
||||||
@@ -34,7 +38,9 @@ public static class SpotDescription
|
|||||||
private static string Comment(string text)
|
private static string Comment(string text)
|
||||||
{
|
{
|
||||||
string clean = new([.. text.Where(c => !char.IsControl(c))]);
|
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;
|
return clean.ToUpperInvariant() is "LSB" or "USB" or "SSB" ? "" : clean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user