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 ++++++++++------ odb/qt/date-time/mysql/qtime-traits.hxx | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) 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; } } }; diff --git a/odb/qt/date-time/mysql/qtime-traits.hxx b/odb/qt/date-time/mysql/qtime-traits.hxx index ad4ff10..4fbf4dd 100644 --- a/odb/qt/date-time/mysql/qtime-traits.hxx +++ b/odb/qt/date-time/mysql/qtime-traits.hxx @@ -32,9 +32,12 @@ namespace odb // v.setHMS (24, 0, 0); else + // Since MySQL 5.6.4, the microseconds part is no longer ignored. + // v.setHMS (static_cast (i.hour), static_cast (i.minute), - static_cast (i.second)); + static_cast (i.second), + static_cast (i.second_part / 1000)); } static void @@ -54,8 +57,7 @@ namespace odb i.hour = static_cast (v.hour ()); i.minute = static_cast (v.minute ()); i.second = static_cast (v.second ()); - - i.second_part = 0; + i.second_part = static_cast (v.msec ()) * 1000; } } }; -- cgit v1.1