public override object ConvertToTypeLimits(ISessionInterface session, object a) { if (a == null) { return(null); } IntervalMonthData data = a as IntervalMonthData; if (data != null) { if (data.Units > this.GetIntervalValueLimit()) { throw Error.GetError(0xd6b); } } else { IntervalSecondData data2 = a as IntervalSecondData; if ((data2 != null) && (data2.Units > this.GetIntervalValueLimit())) { throw Error.GetError(0xd6b); } } return(a); }
public override object Absolute(object a) { if (a == null) { return(null); } IntervalMonthData data = a as IntervalMonthData; if (data != null) { if (data.Units < 0L) { return(this.Negate(a)); } } else { IntervalSecondData data2 = (IntervalSecondData)a; if ((data2.Units < 0L) || (data2.Nanos < 0)) { return(this.Negate(a)); } } return(a); }
public override object Subtract(object a, object b, SqlType aType, SqlType otherType) { if ((a == null) || (b == null)) { return(null); } switch (base.TypeCode) { case 0x5b: { if (!otherType.IsNumberType()) { break; } double num2 = ((double)SqlType.SqlDouble.ConvertToDefaultType(null, b)) * 86400.0; return(AddSeconds((TimestampData)a, -((int)num2), 0)); } case 0x5c: case 0x5e: { if (b is IntervalMonthData) { throw Error.RuntimeError(0xc9, "DateTimeType"); } IntervalSecondData data4 = b as IntervalSecondData; if (data4 == null) { goto Label_00ED; } return(AddSeconds((TimeData)a, -((int)data4.Units), -data4.Nanos)); } case 0x5d: case 0x5f: break; default: goto Label_00ED; } TimestampData source = (TimestampData)a; IntervalMonthData data2 = b as IntervalMonthData; if (data2 != null) { return(AddMonths(source, -((int)data2.Units))); } IntervalSecondData data3 = b as IntervalSecondData; if (data3 != null) { return(AddSeconds(source, -((int)data3.Units), -data3.Nanos)); } Label_00ED: throw Error.RuntimeError(0xc9, "DateTimeType"); }
public override object Negate(object a) { if (a == null) { return(null); } IntervalMonthData data = a as IntervalMonthData; if (data != null) { return(new IntervalMonthData(-data.Units, this)); } IntervalSecondData data1 = (IntervalSecondData)a; long units = data1.Units; int nanos = data1.Nanos; return(new IntervalSecondData(-units, -((long)nanos), this, true)); }
public override object ConvertToType(ISessionInterface session, object a, SqlType othType) { long units; int nanos; if (a == null) { return(null); } int typeCode = othType.TypeCode; if (typeCode > 0x19) { switch (typeCode) { case 100: goto Label_023D; case 0x65: return(new IntervalMonthData((((IntervalMonthData)a).Units / 12L) * 12L, this)); case 0x66: case 0x6b: return(new IntervalMonthData(((IntervalMonthData)a).Units, this)); case 0x67: return(new IntervalSecondData((((IntervalSecondData)a).Units / ((long)DTIType.YearToSecondFactors[2])) * DTIType.YearToSecondFactors[2], 0, this)); case 0x68: case 0x69: case 0x6c: case 0x6d: case 0x6f: return(new IntervalSecondData((((IntervalSecondData)a).Units / ((long)DTIType.YearToSecondFactors[base.EndPartIndex])) * DTIType.YearToSecondFactors[base.EndPartIndex], 0, this)); case 0x6a: case 110: case 0x70: case 0x71: { IntervalSecondData data1 = (IntervalSecondData)a; units = data1.Units; nanos = data1.Nanos; if (base.Scale != 0) { nanos = (nanos / DTIType.NanoScaleFactors[base.Scale]) * DTIType.NanoScaleFactors[base.Scale]; } else { nanos = 0; } goto Label_022A; } case 40: a = a.ToString(); goto Label_023D; } goto Label_0251; } switch (typeCode) { case -6: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 0x19: { if ((a is decimal) && !NumberType.IsInLongLimits((decimal)a)) { throw Error.GetError(0xd6b); } long years = Convert.ToInt64(a); switch (base.EndIntervalType) { case 0x65: return(IntervalMonthData.NewIntervalYear(years, this)); case 0x66: return(IntervalMonthData.NewIntervalMonth(years, this)); case 0x67: return(IntervalSecondData.NewIntervalDay(years, this)); case 0x68: return(IntervalSecondData.NewIntervalHour(years, this)); case 0x69: return(IntervalSecondData.NewIntervalMinute(years, this)); case 0x6a: { int nanos = 0; if ((base.Scale > 0) && (a is decimal)) { nanos = (int)NumberType.ScaledDecimal(a, 9); } return(new IntervalSecondData(years, nanos, this)); } } throw Error.GetError(0x15b9); } case 1: case 12: goto Label_023D; default: goto Label_0251; } Label_022A: return(new IntervalSecondData(units, nanos, this)); Label_023D: return(session.GetScanner().ConvertToDatetimeInterval(session, (string)a, this)); Label_0251: throw Error.GetError(0x15b9); }
public override object Subtract(object a, object b, SqlType aType, SqlType otherType) { if ((a == null) || (b == null)) { return(null); } switch (base.TypeCode) { case 0x65: case 0x66: case 0x6b: { IntervalMonthData data = a as IntervalMonthData; IntervalMonthData data2 = b as IntervalMonthData; if ((data == null) || (data2 == null)) { TimestampData data3 = a as TimestampData; TimestampData data4 = b as TimestampData; if ((data3 == null) || (data4 == null)) { throw Error.RuntimeError(0xc9, "IntervalType"); } bool isYear = base.TypeCode == 0x65; return(new IntervalMonthData((long)DateTimeType.SubtractMonths(data3, data4, isYear), this)); } return(new IntervalMonthData(data.Units - data2.Units, this)); } case 0x67: case 0x68: case 0x69: case 0x6a: case 0x6c: case 0x6d: case 110: case 0x6f: case 0x70: case 0x71: { IntervalSecondData data5 = a as IntervalSecondData; IntervalSecondData data6 = b as IntervalSecondData; if ((data5 == null) || (data6 == null)) { TimeData data7 = a as TimeData; TimeData data8 = b as TimeData; if ((data7 != null) && (data8 != null)) { long num4 = data7.GetSeconds() - data8.GetSeconds(); return(new IntervalSecondData(num4, data7.GetNanos() - data8.GetNanos(), this, true)); } TimestampData data9 = a as TimestampData; TimestampData data10 = b as TimestampData; if ((data9 != null) && (data10 != null)) { long num6 = data9.GetSeconds() - data10.GetSeconds(); return(new IntervalSecondData(num6, data9.GetNanos() - data10.GetNanos(), this, true)); } break; } long seconds = data5.Units - data6.Units; return(new IntervalSecondData(seconds, data5.Nanos - data6.Nanos, this, true)); } } throw Error.RuntimeError(0xc9, "IntervalType"); }