diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-20 20:33:05 -0500 |
| commit | 767cdc1f6f6a63ce997fc9476911e2c361f9d402 (patch) | |
| tree | 49add55976f895441167c66cfa95e5c7688d18ce /MediaBrowser.UI/Converters/DateTimeToStringConverter.cs | |
| parent | 845554722efaed872948a9e0f7202e3ef52f1b6e (diff) | |
Pushing missing changes
Diffstat (limited to 'MediaBrowser.UI/Converters/DateTimeToStringConverter.cs')
| -rw-r--r-- | MediaBrowser.UI/Converters/DateTimeToStringConverter.cs | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs b/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs index 6c568c061..f0c93e7d5 100644 --- a/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs +++ b/MediaBrowser.UI/Converters/DateTimeToStringConverter.cs @@ -1,34 +1,41 @@ -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();
- }
- }
-}
+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 a theme asks for this, they know it's only going to work if the current culture is en-us + if (format.Equals("timesuffixlower", StringComparison.OrdinalIgnoreCase)) + { + if (CultureInfo.CurrentCulture.Name.Equals("en-US", StringComparison.OrdinalIgnoreCase)) + { + var time = date.ToString("t"); + var values = time.Split(' '); + return values[values.Length - 1].ToLower(); + } + return string.Empty; + } + + return date.ToString(format); + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} |
