public static FullViewDateTimeConverter GetHourlyDateTimeConverter()
 {
     if (hdt == null)
     {
         hdt = new FullViewDateTimeConverter();
     }
     return hdt;
 }
Esempio n. 2
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var converter = new FullViewDateTimeConverter();
            if (value != null)
            {
                TimeSpan difference = (DateTime)value - DateTime.Now;
                if (difference.Duration() > TimeSpan.FromHours(2))
                    return converter.Convert(value, targetType, parameter, culture);

                if (difference < TimeSpan.FromTicks(0))
                    return String.Format("{0} {1}", GetRelativeTime(difference.Duration(), true), AppResources.TimeConverterAgoWord);
                else
                    return String.Format("{0}{1}", AppResources.TimeConverterInWord, GetRelativeTime(difference.Duration(), false));
            }
            return "";
        }