public static string ToString(DateTime dateValue, SQLiteDateFormats format, DateTimeKind kind, string formatString)
        {
            DateTime dateTime;

            switch (format)
            {
            case SQLiteDateFormats.Ticks:
            {
                return(dateValue.Ticks.ToString(CultureInfo.InvariantCulture));
            }

            case SQLiteDateFormats.ISO8601:
            {
                if (dateValue.Kind != DateTimeKind.Unspecified)
                {
                    return(dateValue.ToString(SQLiteConvert.GetDateTimeKindFormat(dateValue.Kind, formatString), CultureInfo.InvariantCulture));
                }
                dateTime = DateTime.SpecifyKind(dateValue, kind);
                return(dateTime.ToString(SQLiteConvert.GetDateTimeKindFormat(kind, formatString), CultureInfo.InvariantCulture));
            }

            case SQLiteDateFormats.JulianDay:
            {
                return(SQLiteConvert.ToJulianDay(dateValue).ToString(CultureInfo.InvariantCulture));
            }

            case SQLiteDateFormats.UnixEpoch:
            {
                TimeSpan timeSpan = dateValue.Subtract(SQLiteConvert.UnixEpoch);
                return((timeSpan.Ticks / (long)10000000).ToString());
            }

            case SQLiteDateFormats.InvariantCulture:
            {
                return(dateValue.ToString((formatString != null ? formatString : "yyyy-MM-ddTHH:mm:ss.fffffffK"), CultureInfo.InvariantCulture));
            }

            case SQLiteDateFormats.CurrentCulture:
            {
                return(dateValue.ToString((formatString != null ? formatString : "yyyy-MM-ddTHH:mm:ss.fffffffK"), CultureInfo.CurrentCulture));
            }

            default:
            {
                if (dateValue.Kind != DateTimeKind.Unspecified)
                {
                    return(dateValue.ToString(SQLiteConvert.GetDateTimeKindFormat(dateValue.Kind, formatString), CultureInfo.InvariantCulture));
                }
                dateTime = DateTime.SpecifyKind(dateValue, kind);
                return(dateTime.ToString(SQLiteConvert.GetDateTimeKindFormat(kind, formatString), CultureInfo.InvariantCulture));
            }
            }
        }