using System; using System.Runtime.CompilerServices; using Windows.UI.Xaml.Data; namespace OwlCore.WinUI.Converters.Time.Numerical { /// /// A converter that converts a given to a natural time format string. /// /// /// "1 Hr 4 Min 40 Sec" /// public sealed class DateTimeToShortTextConverter : IValueConverter { /// /// Converts a to a formatted string. /// /// The to convert. /// A formatted string of the . [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string Convert(TimeSpan value) { // "d" represents system short time format return value.ToString("d"); } /// public object Convert(object value, Type targetType, object parameter, string language) { if (value is TimeSpan timeSpan) { return Convert(timeSpan); } return Convert(TimeSpan.Zero); } /// public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } }