From 2c12838925dc6fbc7d45ada0ddc40871c6a5d56b Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Sun, 4 Dec 2011 23:30:58 +0200 Subject: Handle microsecond resolution in PostgreSQL Qt date-time mappings --- odb/qt/date-time/pgsql/qtime-traits.hxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'odb/qt/date-time/pgsql/qtime-traits.hxx') diff --git a/odb/qt/date-time/pgsql/qtime-traits.hxx b/odb/qt/date-time/pgsql/qtime-traits.hxx index c822017..22b8326 100644 --- a/odb/qt/date-time/pgsql/qtime-traits.hxx +++ b/odb/qt/date-time/pgsql/qtime-traits.hxx @@ -38,8 +38,12 @@ namespace odb // v.setHMS (24, 0, 0); else - v = QTime (0, 0, 0).addSecs ( - static_cast (endian_traits::ntoh (i) / 1000000)); + { + const QTime base (0, 0, 0); + + v = base.addMSecs ( + static_cast (endian_traits::ntoh (i) / 1000)); + } } static void @@ -50,8 +54,10 @@ namespace odb else { is_null = false; + const QTime base (0, 0, 0); + i = endian_traits::hton ( - static_cast (QTime (0, 0, 0).secsTo (v)) * 1000000); + static_cast (base.msecsTo (v)) * 1000); } } }; -- cgit v1.1