namespace Volcanic.AgenticCore.Extensions.Scheduler;
///
/// Zone ids for display and TZ. Mirrors the core's Volcanic.AgenticCore.Hosting.TimeZoneIds (the extension
/// references only the Abstractions); keep the two in step.
///
internal static class ZoneNames
{
///
/// The IANA id (converting a Windows id), or null when there is none that resolves back to a system zone (an unnamed
/// Local zone: TZ=Local would run the script in UTC). Same rule as TimeZoneIds.ToIana.
///
public static string? Iana(TimeZoneInfo zone)
{
if (string.Equals(zone.Id, "Local", StringComparison.OrdinalIgnoreCase)) return null;
var id = zone.HasIanaId ? zone.Id : TimeZoneInfo.TryConvertWindowsIdToIanaId(zone.Id, out var iana) ? iana : null;
return id is not null && TimeZoneInfo.TryFindSystemTimeZoneById(id, out _) ? id : null;
}
/// The IANA id when there is one, else the zone's own id (TimeZoneIds.Name).
public static string Name(TimeZoneInfo zone) => Iana(zone) ?? zone.Id;
}