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 object ConvertSQLToCSharp(ISessionInterface session, object a) { if (a == null) { return(null); } switch (base.TypeCode) { case 0x5b: { long seconds = ((TimestampData)a).GetSeconds(); seconds = UtlDateTime.ConvertTicksToTimeZone(session.GetTimeZone(), seconds * 0x989680L) / 0x989680L; return(new DateTime(UtlDateTime.GetNormalisedDate(seconds) * 0x989680L)); } case 0x5c: { long seconds = ((TimeData)a).GetSeconds(); seconds = UtlDateTime.ConvertTicksToTimeZone(session.GetTimeZone(), seconds * 0x989680L) / 0x989680L; return(new DateTime(UtlDateTime.GetNormalisedTime(seconds) * 0x989680L)); } case 0x5d: { TimestampData data = (TimestampData)a; long seconds = data.GetSeconds(); seconds = UtlDateTime.ConvertTicksToTimeZone(session.GetTimeZone(), seconds * 0x989680L) / 0x989680L; return(new DateTime((seconds * 0x989680L) + (data.GetNanos() / 100))); } case 0x5e: { TimeData data2 = (TimeData)a; return(new DateTime(UtlDateTime.GetNormalisedTime((long)(data2.GetSeconds() + data2.GetZone())) * 0x989680L)); } case 0x5f: { TimestampData data3 = (TimestampData)a; return(new DateTime((data3.GetSeconds() * 0x989680L) + (data3.GetNanos() / 100))); } } throw Error.RuntimeError(0xc9, "DateTimeType"); }
public override int GetPart(Session session, object dateTime, int part) { long num; if ((base.TypeCode == 0x5c) || (base.TypeCode == 0x5e)) { TimeData data = (TimeData)dateTime; num = (data.GetSeconds() + data.GetZone()) * 0x989680L; } else { TimestampData data2 = (TimestampData)dateTime; num = (data2.GetSeconds() + data2.GetZone()) * 0x989680L; } DateTime time = new DateTime(num); switch (part) { case 0x65: return(time.Year); case 0x66: return(time.Month); case 0x67: case 260: return(time.Day); case 0x68: return(time.Hour); case 0x69: return(time.Minute); case 0x6a: return(time.Second); case 0x101: if (base.TypeCode != 0x5f) { return(((TimeData)dateTime).GetZone() / 0xe10); } return(((TimestampData)dateTime).GetZone() / 0xe10); case 0x102: if (base.TypeCode != 0x5f) { return((((TimeData)dateTime).GetZone() / 60) % 60); } return((((TimestampData)dateTime).GetZone() / 60) % 60); case 0x103: return(((int)time.DayOfWeek) + 1); case 0x105: return(time.DayOfYear); case 0x106: return(CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(time, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)); case 0x107: return(((time.Month - 1) / 3) + 1); case 0x10a: if ((base.TypeCode != 0x5c) && (base.TypeCode != 0x5e)) { try { dateTime = (this._withTimeZone ? SqlType.SqlTimeWithTimeZone : SqlType.SqlTime).CastToType(session, dateTime, this); } catch (CoreException) { } } return(((TimeData)dateTime).GetSeconds()); } throw Error.RuntimeError(0xc9, "DateTimeType - " + part); }