Changeset View
Changeset View
Standalone View
Standalone View
src/drivers/postgresql/PostgresqlCursor.cpp
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Line(s) | |||||
180 | static inline QTime timeFromData(const char *data, int len) | 180 | static inline QTime timeFromData(const char *data, int len) | ||
181 | { | 181 | { | ||
182 | if (len == 0) { | 182 | if (len == 0) { | ||
183 | return QTime(); | 183 | return QTime(); | ||
184 | } | 184 | } | ||
185 | QString s(QString::fromLatin1(data, len)); | 185 | QString s(QString::fromLatin1(data, len)); | ||
186 | if (hasTimeZone(s)) { | 186 | if (hasTimeZone(s)) { | ||
187 | s.chop(3); // skip timezone | 187 | s.chop(3); // skip timezone | ||
188 | return QTime::fromString(s, Qt::ISODate); | | |||
189 | } | 188 | } | ||
190 | return QTime::fromString(s, Qt::ISODate); | 189 | return QTime::fromString(s, Qt::ISODateWithMs); | ||
191 | } | 190 | } | ||
192 | 191 | | |||
193 | static inline QDateTime dateTimeFromData(const char *data, int len) | 192 | static inline QDateTime dateTimeFromData(const char *data, int len) | ||
194 | { | 193 | { | ||
195 | if (len < 10 /*ISO Date*/) { | 194 | if (len < 10 /*ISO Date*/) { | ||
196 | return QDateTime(); | 195 | return QDateTime(); | ||
197 | } | 196 | } | ||
198 | QString s(QString::fromLatin1(data, len)); | 197 | QString s(QString::fromLatin1(data, len)); | ||
199 | if (hasTimeZone(s)) { | 198 | if (hasTimeZone(s)) { | ||
200 | s.chop(3); // skip timezone | 199 | s.chop(3); // skip timezone | ||
201 | if (s.isEmpty()) { | 200 | if (s.isEmpty()) { | ||
202 | return QDateTime(); | 201 | return QDateTime(); | ||
203 | } | 202 | } | ||
204 | } | 203 | } | ||
205 | if (s.at(s.length() - 3).isPunct()) { // fix ms, should be three digits | 204 | if (s.at(s.length() - 3).isPunct()) { // fix ms, should be three digits | ||
206 | s += QLatin1Char('0'); | 205 | s += QLatin1Char('0'); | ||
207 | } | 206 | } | ||
208 | return QDateTime::fromString(s, Qt::ISODate); | 207 | return QDateTime::fromString(s, Qt::ISODateWithMs); | ||
209 | } | 208 | } | ||
210 | 209 | | |||
211 | static inline QByteArray byteArrayFromData(const char *data) | 210 | static inline QByteArray byteArrayFromData(const char *data) | ||
212 | { | 211 | { | ||
213 | size_t unescapedLen; | 212 | size_t unescapedLen; | ||
214 | unsigned char *unescapedData = PQunescapeBytea((const unsigned char*)data, &unescapedLen); | 213 | unsigned char *unescapedData = PQunescapeBytea((const unsigned char*)data, &unescapedLen); | ||
215 | const QByteArray result((const char*)unescapedData, unescapedLen); | 214 | const QByteArray result((const char*)unescapedData, unescapedLen); | ||
216 | //! @todo avoid deep copy; QByteArray does not allow passing ownership of data; maybe copy PQunescapeBytea code? | 215 | //! @todo avoid deep copy; QByteArray does not allow passing ownership of data; maybe copy PQunescapeBytea code? | ||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |