public static object Multiply(object x, object y) { if (ObjectValue.IsBool(x, y)) { return(BooleanValue.Multiply((bool)x, (bool)y)); } if (ObjectValue.IsAnyDouble(x, y)) { return(DoubleMath.Multiply(DoubleValue.ToDouble(x), DoubleValue.ToDouble(y))); } if (ObjectValue.IsAnyDecimal(x, y)) { return(DecimalValue.Multiply(DecimalValue.ToDecimal(x), DecimalValue.ToDecimal(y))); } return(null); }
public static object Subtract(object x, object y) { if (ObjectValue.IsDateTime(x, y)) { return(DateTimeMath.Subtract((DateTime)x, (DateTime)y)); } if (ObjectValue.IsAnyDouble(x, y)) { return(DoubleMath.Subtract(DoubleValue.ToDouble(x), DoubleValue.ToDouble(y))); } if (ObjectValue.IsAnyDecimal(x, y)) { return(DecimalValue.Subtract(DecimalValue.ToDecimal(x), DecimalValue.ToDecimal(y))); } return(null); }
public static object Add(object x, object y) { if (ObjectValue.IsBool(x, y)) { return(BooleanValue.Add((bool)x, (bool)y)); } if (ObjectValue.IsString(x, y)) { return(StringValue.Add((string)x, (string)y)); } if (ObjectValue.IsDateTime(x, y)) { return(DateTimeMath.Add((DateTime)x, (DateTime)y)); } if (ObjectValue.IsAnyDouble(x, y)) { return(DoubleMath.Add(DoubleValue.ToDouble(x), DoubleValue.ToDouble(y))); } if (ObjectValue.IsAnyDecimal(x, y)) { return(DecimalValue.Add(DecimalValue.ToDecimal(x), DecimalValue.ToDecimal(y))); } return(null); }
public static DateTime ReplaceTime(string s, DateTime d) { if (IsNullOrEmpty(s)) { return(d); } double f; DateTime d1; if ((s.Length > 8) && double.TryParse(s.Trim(), NumberStyles.Any, UseCulture.English, out f)) { s = DoubleValue.ToString(f / 0.000011574074074074067); if ((s.IndexOf('.') < 0) && (s.Length < 3)) { s = s + "."; } if (s.IndexOf('.') == 1) { s = "0" + s; } if (s.IndexOf('.') == 1) { s = "0" + s; } if (s.Length > 5) { s = s.Substring(0, 5); } if (s.Length < 5) { s = AddChars(s, 5, '0', PositionCode.End); } } var date = string.Format("{0} {1}", DateTimeValue.ToShortDateString(d), DateTimePattern.LongMorning); DateTimeValue.TryParse(date, out d1); s = s.Trim(); s = RemoveAllExcept(s, "0123456789;:."); s = ReplaceAll(s, '.', ':'); s = ReplaceAll(s, ';', ':'); if (s == string.Empty) { s = DateTimePattern.LongMorning; } s = DateTimeValue.ToCorrectHours(s); s = DateTimeValue.ToShortTimeString(s); s = DateTimeValue.ToLongTimeString(s); date = DateTimeValue.ToShortDateString(d); date = string.Format("{0} {1}", date, s); DateTime d2; DateTimeValue.TryParse(date, out d2); if (d2 != DateTime.MinValue) { return(d2); } if (d1 != DateTime.MinValue) { return(d1); } return(d); }