LANCommander/LANCommander.Launcher/Converters/DateTimeOffsetToTimeStringConverter.cs

22 lines
755 B
C#
Raw Permalink Normal View History

2026-04-07 23:10:45 -05:00
using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace LANCommander.Launcher.Converters;
2026-04-07 23:10:45 -05:00
/// <summary>Formats a DateTimeOffset as a short local-time string (HH:mm).</summary>
public class DateTimeOffsetToTimeStringConverter : IValueConverter
{
public static readonly DateTimeOffsetToTimeStringConverter Instance = new();
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is DateTimeOffset dto)
return dto.LocalDateTime.ToString("HH:mm", culture);
return string.Empty;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}