2025-09-04 18:28:02 +08:00

33 lines
890 B
C#

using System;
using System.Globalization;
using System.Windows.Data;
using SWS.Model;
namespace SWS.Commons.Helper.Converter
{
public class TimeSpanValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is TimeSpan timeSpan)
{
if (timeSpan< TimeSpan.Zero)
{
return $"-{timeSpan:%d}天 {timeSpan:hh\\:mm\\:ss}";
}
else
{
return $"{timeSpan:%d}天 {timeSpan:hh\\:mm\\:ss}";
}
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}