/// <summary> /// Converts the back. /// </summary> /// <param name="value">The value.</param> /// <param name="targetType">Type of the target.</param> /// <param name="parameter">The parameter.</param> /// <param name="language">The language.</param> /// <returns>System.Object.</returns> public object ConvertBack(object value, Type targetType, object parameter, string language) { if (original is DateTimeOffset odt && value is TimeSpan ts) { var dt = DateTimeOffsetConverter.TimeSpanToDateTimeOffset(odt, ts); return(dt.GetValueOrDefault(DateTimeOffset.MinValue)); } return(DateTimeOffset.MinValue); }
/// <summary> /// Converts the specified value. /// </summary> /// <param name="value">The value.</param> /// <param name="targetType">Type of the target.</param> /// <param name="parameter">The parameter.</param> /// <param name="language">The language.</param> /// <returns>System.Object.</returns> public object Convert(object value, Type targetType, object parameter, string language) { if (value is DateTimeOffset dt) { original = dt; var ts = DateTimeOffsetConverter.DateTimeOffsetToTimeSpan(dt); return(ts.GetValueOrDefault(TimeSpan.MinValue)); } return(TimeSpan.MinValue); }