public static TimeData AddSeconds(TimeData source, int seconds, int nanos) { nanos += source.GetNanos(); seconds += nanos / 0x3b9aca00; nanos = nanos % 0x3b9aca00; if (nanos < 0) { nanos += 0x3b9aca00; seconds--; } seconds += source.GetSeconds(); seconds = seconds % 0x15180; return(new TimeData((long)seconds, nanos, source.GetZone())); }
public override string ConvertToString(object a) { if (a == null) { return(null); } switch (base.TypeCode) { case 0x5b: return(UtlDateTime.GetDateString(((TimestampData)a).GetSeconds())); case 0x5c: case 0x5e: { TimeData data = (TimeData)a; int num2 = NormaliseTime(data.GetSeconds() + data.GetZone()); string str2 = base.IntervalSecondToString((long)num2, data.GetNanos(), false); if (this._withTimeZone) { str2 = SqlType.SqlIntervalHourToMinute.IntervalSecondToString((long)data.GetZone(), 0, true); StringBuilder builder1 = new StringBuilder(str2); builder1.Append(str2); return(builder1.ToString()); } return(str2); } case 0x5d: case 0x5f: { TimestampData data2 = (TimestampData)a; StringBuilder sb = new StringBuilder(); UtlDateTime.GetTimestampString(sb, data2.GetSeconds() + data2.GetZone(), data2.GetNanos(), base.Scale); if (this._withTimeZone) { string str3 = SqlType.SqlIntervalHourToMinute.IntervalSecondToString((long)data2.GetZone(), 0, true); sb.Append(str3); return(sb.ToString()); } return(sb.ToString()); } } throw Error.RuntimeError(0xc9, "DateTimeType"); }
public override object ConvertToTypeLimits(ISessionInterface session, object a) { if (a == null) { return(null); } if (base.Scale == 9) { return(a); } switch (base.TypeCode) { case 0x5b: return(a); case 0x5c: case 0x5e: { TimeData data = (TimeData)a; int nanos = data.GetNanos(); int num3 = this.ScaleNanos(nanos); if (num3 != nanos) { return(new TimeData((long)data.GetSeconds(), num3, data.GetZone())); } return(data); } case 0x5d: case 0x5f: { TimestampData data2 = (TimestampData)a; int nanos = data2.GetNanos(); int num5 = this.ScaleNanos(nanos); if (num5 != nanos) { return(new TimestampData(data2.GetSeconds(), num5, data2.GetZone())); } return(data2); } } throw Error.RuntimeError(0xc9, "DateTimeType"); }
public object ChangeZone(object a, SqlType otherType, int targetZone, int localZone) { if (a == null) { return(null); } if ((otherType.TypeCode == 0x5f) || (otherType.TypeCode == 0x5e)) { localZone = 0; } if ((targetZone > DTIType.TimezoneSecondsLimit) || (-targetZone > DTIType.TimezoneSecondsLimit)) { throw Error.GetError(0xd51); } switch (base.TypeCode) { case 0x5e: { TimeData data = (TimeData)a; if ((localZone == 0) && (data.GetZone() == targetZone)) { return(a); } return(new TimeData((long)(data.GetSeconds() - localZone), data.GetNanos(), targetZone)); } case 0x5f: { TimestampData data2 = (TimestampData)a; if ((localZone == 0) && (data2.GetZone() == targetZone)) { return(a); } return(new TimestampData(data2.GetSeconds() - localZone, data2.GetNanos(), targetZone)); } } return(a); }
public override object ConvertToType(ISessionInterface session, object a, SqlType othType) { if (a == null) { return(a); } switch (othType.TypeCode) { case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: goto Label_0126; case 100: case 1: case 12: break; case 40: case 0x19: case 3: case 4: case 8: a = a.ToString(); break; default: throw Error.GetError(0x15b9); } int typeCode = base.TypeCode; if (typeCode != 0x5b) { if ((typeCode - 0x5c) <= 3) { goto Label_0105; } goto Label_0126; } try { DateTime time = DateTime.Parse((string)a, CultureInfo.InvariantCulture); long seconds = time.Ticks / 0x989680L; long num4 = (time.Ticks - (seconds * 0x989680L)) * 100L; return(new TimestampData(seconds, (int)num4)); } catch (Exception) { return(session.GetScanner().ConvertToDatetimeInterval(session, (string)a, this)); } Label_0105: return(session.GetScanner().ConvertToDatetimeInterval(session, (string)a, this)); Label_0126: switch (base.TypeCode) { case 0x5b: switch (othType.TypeCode) { case 0x5b: return(a); case 0x5d: return(new TimestampData(UtlDateTime.GetNormalisedDate(((TimestampData)a).GetSeconds()))); case 0x5f: return(new TimestampData(UtlDateTime.GetNormalisedDate(((TimestampData)a).GetSeconds() + ((TimestampData)a).GetZone()))); } break; case 0x5c: switch (othType.TypeCode) { case 0x5c: return(this.ConvertToTypeLimits(session, a)); case 0x5d: { TimestampData data = (TimestampData)a; return(new TimeData((long)((int)data.GetSeconds()), this.ScaleNanos(data.GetNanos()))); } case 0x5e: { TimeData data2 = (TimeData)a; return(new TimeData((long)(data2.GetSeconds() + data2.GetZone()), this.ScaleNanos(data2.GetNanos()), 0)); } case 0x5f: { TimestampData data3 = (TimestampData)a; return(new TimeData((long)(((int)data3.GetSeconds()) + data3.GetZone()), this.ScaleNanos(data3.GetNanos()), 0)); } } throw Error.GetError(0x15b9); case 0x5d: switch (othType.TypeCode) { case 0x5b: return(a); case 0x5c: { TimeData data4 = (TimeData)a; return(new TimestampData(session.GetCurrentDate().GetSeconds() + data4.GetSeconds(), this.ScaleNanos(data4.GetNanos()))); } case 0x5d: return(this.ConvertToTypeLimits(session, a)); case 0x5e: { TimeData data5 = (TimeData)a; return(new TimestampData((session.GetCurrentDate().GetSeconds() + data5.GetSeconds()) - session.GetZoneSeconds(), this.ScaleNanos(data5.GetNanos()), session.GetZoneSeconds())); } case 0x5f: { TimestampData data6 = (TimestampData)a; return(new TimestampData(data6.GetSeconds() + data6.GetZone(), this.ScaleNanos(data6.GetNanos()))); } } throw Error.GetError(0x15b9); case 0x5e: switch (othType.TypeCode) { case 0x5c: { TimeData data7 = (TimeData)a; return(new TimeData((long)(data7.GetSeconds() - session.GetZoneSeconds()), this.ScaleNanos(data7.GetNanos()), session.GetZoneSeconds())); } case 0x5d: { TimestampData data8 = (TimestampData)a; return(new TimeData((long)(((int)data8.GetSeconds()) - session.GetZoneSeconds()), this.ScaleNanos(data8.GetNanos()), session.GetZoneSeconds())); } case 0x5e: return(this.ConvertToTypeLimits(session, a)); case 0x5f: { TimestampData data9 = (TimestampData)a; return(new TimeData((long)((int)data9.GetSeconds()), this.ScaleNanos(data9.GetNanos()), data9.GetZone())); } } throw Error.GetError(0x15b9); case 0x5f: switch (othType.TypeCode) { case 0x5b: return(new TimestampData(((TimestampData)a).GetSeconds(), 0, session.GetZoneSeconds())); case 0x5c: { TimeData data10 = (TimeData)a; return(new TimestampData((session.GetCurrentDate().GetSeconds() + data10.GetSeconds()) - session.GetZoneSeconds(), this.ScaleNanos(data10.GetNanos()), session.GetZoneSeconds())); } case 0x5d: { TimestampData data11 = (TimestampData)a; return(new TimestampData(data11.GetSeconds() - session.GetZoneSeconds(), this.ScaleNanos(data11.GetNanos()), session.GetZoneSeconds())); } case 0x5e: { TimeData data12 = (TimeData)a; return(new TimestampData(session.GetCurrentDate().GetSeconds() + data12.GetSeconds(), this.ScaleNanos(data12.GetNanos()), data12.GetZone())); } case 0x5f: return(this.ConvertToTypeLimits(session, a)); } throw Error.GetError(0x15b9); default: throw Error.RuntimeError(0xc9, "DateTimeType"); } throw Error.GetError(0x15b9); }
public override int Compare(Session session, object a, object b, SqlType otherType, bool forEquality) { if (a == b) { return(0); } if (a == null) { return(-1); } if (b == null) { return(1); } switch (base.TypeCode) { case 0x5b: case 0x5d: case 0x5f: { TimestampData data = (TimestampData)a; TimestampData data2 = (TimestampData)b; long num3 = data.GetSeconds() - data2.GetSeconds(); if (num3 == 0) { num3 = data.GetNanos() - data2.GetNanos(); } if (num3 == 0) { return(0); } if (num3 <= 0L) { return(-1); } return(1); } case 0x5c: case 0x5e: { TimeData data3 = (TimeData)a; TimeData data4 = (TimeData)b; long num4 = data3.GetSeconds() - data4.GetSeconds(); if (num4 == 0) { num4 = data3.GetNanos() - data4.GetNanos(); } if (num4 == 0) { return(0); } if (num4 <= 0L) { return(-1); } return(1); } } throw Error.RuntimeError(0xc9, "DateTimeType"); }
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"); }