aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.UI/Converters/DateTimeToStringConverter.cs')
-rw-r--r--MediaBrowser.UI/Converters/DateTimeToStringConverter.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs b/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs
new file mode 100644
index 000000000..6c568c061
--- /dev/null
+++ b/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs
@@ -0,0 +1,34 @@
+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();
+ }
+ }
+}