diff options
Diffstat (limited to 'odb/qt/date-time/sqlite/qdate-traits.hxx')
-rw-r--r-- | odb/qt/date-time/sqlite/qdate-traits.hxx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/odb/qt/date-time/sqlite/qdate-traits.hxx b/odb/qt/date-time/sqlite/qdate-traits.hxx index 2810d02..52721b7 100644 --- a/odb/qt/date-time/sqlite/qdate-traits.hxx +++ b/odb/qt/date-time/sqlite/qdate-traits.hxx @@ -10,7 +10,10 @@ #include <cstddef> // std::size_t #include <cstring> // std::memcpy +#include <QtCore/QtGlobal> // QT_VERSION + #include <QtCore/QDate> +#include <QtCore/QDateTime> #include <odb/details/buffer.hxx> #include <odb/sqlite/traits.hxx> @@ -92,8 +95,14 @@ namespace odb { QDateTime dt; dt.setTimeSpec (Qt::UTC); - dt.setTime_t (static_cast<uint> (i)); + // *Time_t() functions are deprecated in favor of *SecsSinceEpoch(). + // +#if QT_VERSION < 0x060000 + dt.setTime_t (static_cast<uint> (i)); +#else + dt.setSecsSinceEpoch (static_cast<qint64> (i)); +#endif v = dt.date (); } } @@ -108,8 +117,13 @@ namespace odb else { is_null = false; - i = static_cast<long long> ( - QDateTime (v, QTime (0, 0, 0), Qt::UTC).toTime_t ()); + const QDateTime dt (v, QTime (0, 0, 0), Qt::UTC); + +#if QT_VERSION < 0x060000 + i = static_cast<long long> (dt.toTime_t ()); +#else + i = static_cast<long long> (dt.toSecsSinceEpoch ()); +#endif } } }; |