public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var d = value as DateOffset; if (d == null) { return(DependencyProperty.UnsetValue); } return(DateOffsetFormatter.GetUnitString(d.Offset, d.Unit)); }
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values.Length < 2 || !(values[0] is DateUnit) || !(values[1] is int?)) { return(DependencyProperty.UnsetValue); } var unit = (DateUnit)values[0]; int?offset = (int?)values[1]; return(DateOffsetFormatter.GetUnitString(offset, unit)); }
public void UnitNegative() { var str = DateOffsetFormatter.GetUnitString(-1, DateUnit.Day); Assert.AreEqual(PluralsHelper.days[0], str); }
public void OffsetNull() { var str = DateOffsetFormatter.GetUnitString(null, DateUnit.Day); Assert.AreEqual(PluralsHelper.days[2], str); }