public static Rounding Build(IColumnDefinition columnDefinition) { if (columnDefinition.Role != ColumnRole.Value) { throw new ArgumentException("The ColumnDefinition must have have a role defined as 'Value' and is defined as 'Key'", "columnDefinition"); } Rounding rounding = null; switch (columnDefinition.Type) { case ColumnType.Text: break; case ColumnType.Numeric: rounding = new NumericRounding(double.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle); break; case ColumnType.DateTime: rounding = new DateTimeRounding(TimeSpan.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle); break; case ColumnType.Boolean: break; default: break; } return(rounding); }
public ComparerResult CompareObjects(object x, object y, DateTimeRounding rounding) { var rxDateTime = ConvertToDate(x); var ryDateTime = ConvertToDate(y); rxDateTime = rounding.GetValue(rxDateTime); ryDateTime = rounding.GetValue(ryDateTime); return(CompareObjects(rxDateTime, ryDateTime)); }
public ComparerResult CompareObjects(object x, object y, DateTimeRounding rounding) { var rxDateTime = ConvertToDate(x); var ryDateTime = ConvertToDate(y); rxDateTime = rounding.GetValue(rxDateTime); ryDateTime = rounding.GetValue(ryDateTime); return CompareObjects(rxDateTime, ryDateTime); }
public static Rounding Build(IColumnDefinition columnDefinition) { if (columnDefinition.Role != ColumnRole.Value) throw new ArgumentException("The ColumnDefinition must have have a role defined as 'Value' and is defined as 'Key'", "columnDefinition"); Rounding rounding=null; switch (columnDefinition.Type) { case ColumnType.Text: break; case ColumnType.Numeric: rounding = new NumericRounding(double.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle); break; case ColumnType.DateTime: rounding = new DateTimeRounding(TimeSpan.Parse(columnDefinition.RoundingStep, NumberFormatInfo.InvariantInfo), columnDefinition.RoundingStyle); break; case ColumnType.Boolean: break; default: break; } return rounding; }
public void GetValue_ValueQuarterHourRoundingStyle_NewValue(DateTime value, Rounding.RoundingStyle roundingStyle, DateTime newValue) { var rounder = new DateTimeRounding(new TimeSpan(0, 0, 15, 0), roundingStyle); Assert.That(rounder.GetValue(value), Is.EqualTo(newValue)); }