internal override DateTime GetDateTime(SQLiteStatement stmt, int index) { if (this._datetimeFormat == SQLiteDateFormats.Ticks) { return(SQLiteConvert.TicksToDateTime(this.GetInt64(stmt, index), this._datetimeKind)); } if (this._datetimeFormat == SQLiteDateFormats.JulianDay) { return(SQLiteConvert.ToDateTime(this.GetDouble(stmt, index), this._datetimeKind)); } if (this._datetimeFormat != SQLiteDateFormats.UnixEpoch) { return(base.ToDateTime(this.GetText(stmt, index))); } return(SQLiteConvert.UnixEpochToDateTime(this.GetInt64(stmt, index), this._datetimeKind)); }
public static DateTime ToDateTime(string dateText, SQLiteDateFormats format, DateTimeKind kind, string formatString) { string str; string[] strArrays; DateTimeFormatInfo invariantInfo; DateTimeStyles dateTimeStyle; string str1; string str2; DateTimeFormatInfo dateTimeFormatInfo; DateTimeStyles dateTimeStyle1; switch (format) { case SQLiteDateFormats.Ticks: { return(SQLiteConvert.TicksToDateTime(Convert.ToInt64(dateText, CultureInfo.InvariantCulture), kind)); } case SQLiteDateFormats.ISO8601: { if (formatString != null) { str1 = dateText; str2 = formatString; dateTimeFormatInfo = DateTimeFormatInfo.InvariantInfo; dateTimeStyle1 = (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None); return(DateTime.SpecifyKind(DateTime.ParseExact(str1, str2, dateTimeFormatInfo, dateTimeStyle1), kind)); } str = dateText; strArrays = SQLiteConvert._datetimeFormats; invariantInfo = DateTimeFormatInfo.InvariantInfo; dateTimeStyle = (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None); return(DateTime.SpecifyKind(DateTime.ParseExact(str, strArrays, invariantInfo, dateTimeStyle), kind)); } case SQLiteDateFormats.JulianDay: { return(SQLiteConvert.ToDateTime(Convert.ToDouble(dateText, CultureInfo.InvariantCulture), kind)); } case SQLiteDateFormats.UnixEpoch: { return(SQLiteConvert.UnixEpochToDateTime(Convert.ToInt64(dateText, CultureInfo.InvariantCulture), kind)); } case SQLiteDateFormats.InvariantCulture: { if (formatString == null) { return(DateTime.SpecifyKind(DateTime.Parse(dateText, DateTimeFormatInfo.InvariantInfo, (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None)), kind)); } return(DateTime.SpecifyKind(DateTime.ParseExact(dateText, formatString, DateTimeFormatInfo.InvariantInfo, (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None)), kind)); } case SQLiteDateFormats.CurrentCulture: { if (formatString == null) { return(DateTime.SpecifyKind(DateTime.Parse(dateText, DateTimeFormatInfo.CurrentInfo, (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None)), kind)); } return(DateTime.SpecifyKind(DateTime.ParseExact(dateText, formatString, DateTimeFormatInfo.CurrentInfo, (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None)), kind)); } default: { if (formatString != null) { str1 = dateText; str2 = formatString; dateTimeFormatInfo = DateTimeFormatInfo.InvariantInfo; dateTimeStyle1 = (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None); return(DateTime.SpecifyKind(DateTime.ParseExact(str1, str2, dateTimeFormatInfo, dateTimeStyle1), kind)); } str = dateText; strArrays = SQLiteConvert._datetimeFormats; invariantInfo = DateTimeFormatInfo.InvariantInfo; dateTimeStyle = (kind == DateTimeKind.Utc ? DateTimeStyles.AdjustToUniversal : DateTimeStyles.None); return(DateTime.SpecifyKind(DateTime.ParseExact(str, strArrays, invariantInfo, dateTimeStyle), kind)); } } }