From d78e3e9ef8084ac21e2d2a24960e6bde9fd3dd5d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 3 Jul 2013 11:57:21 +0200 Subject: Add support for sub-seconds in MySQL --- odb/qt/date-time/mysql/qdate-time-traits.hxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'odb/qt/date-time/mysql/qdate-time-traits.hxx') diff --git a/odb/qt/date-time/mysql/qdate-time-traits.hxx b/odb/qt/date-time/mysql/qdate-time-traits.hxx index 87c62b1..6aa0f55 100644 --- a/odb/qt/date-time/mysql/qdate-time-traits.hxx +++ b/odb/qt/date-time/mysql/qdate-time-traits.hxx @@ -30,12 +30,15 @@ namespace odb // v = QDateTime (); else + // Since MySQL 5.6.4, the microseconds part is no longer ignored. + // v = QDateTime (QDate (static_cast (i.year), static_cast (i.month), static_cast (i.day)), QTime (static_cast (i.hour), static_cast (i.minute), - static_cast (i.second))); + static_cast (i.second), + static_cast (i.second_part / 1000))); } static void @@ -61,8 +64,7 @@ namespace odb i.hour = static_cast (t.hour ()); i.minute = static_cast (t.minute ()); i.second = static_cast (t.second ()); - - i.second_part = 0; + i.second_part = static_cast (t.msec ()) * 1000; } } }; @@ -82,12 +84,15 @@ namespace odb // v = QDateTime (); else + // Since MySQL 5.6.4, the microseconds part is no longer ignored. + // v = QDateTime (QDate (static_cast (i.year), static_cast (i.month), static_cast (i.day)), QTime (static_cast (i.hour), static_cast (i.minute), - static_cast (i.second))); + static_cast (i.second), + static_cast (i.second_part / 1000))); } static void @@ -113,8 +118,7 @@ namespace odb i.hour = static_cast (t.hour ()); i.minute = static_cast (t.minute ()); i.second = static_cast (t.second ()); - - i.second_part = 0; + i.second_part = static_cast (t.msec ()) * 1000; } } }; -- cgit v1.1