mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-22 16:54:46 +03:00
35 lines
934 B
C#
35 lines
934 B
C#
|
|
using System;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
|
|||
|
|
namespace MediaBrowser.UI.Converters
|
|||
|
|
{
|
|||
|
|
public class DateTimeToStringConverter : IValueConverter
|
|||
|
|
{
|
|||
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
var date = (DateTime)value;
|
|||
|
|
|
|||
|
|
string format = parameter as string;
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(format))
|
|||
|
|
{
|
|||
|
|
return date.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (format.Equals("shorttime", StringComparison.OrdinalIgnoreCase))
|
|||
|
|
{
|
|||
|
|
return date.ToShortTimeString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return date.ToString(format);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|||
|
|
{
|
|||
|
|
throw new NotImplementedException();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|