diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-07-03 11:57:21 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-07-03 11:58:03 +0200 |
commit | 1e4a0de189cab11858c977961b884872728abaf0 (patch) | |
tree | 1e12ab12f4c8a31d8780c0ebefb4d8af131e6f32 /odb/qt/date-time/mysql/qdate-time-traits.hxx | |
parent | c79ec4a52b71135a2cdd3a97560a46f461334482 (diff) |
Add support for sub-seconds in MySQL
Diffstat (limited to 'odb/qt/date-time/mysql/qdate-time-traits.hxx')
-rw-r--r-- | odb/qt/date-time/mysql/qdate-time-traits.hxx | 16 |
1 files changed, 10 insertions, 6 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<int> (i.year), static_cast<int> (i.month), static_cast<int> (i.day)), QTime (static_cast<int> (i.hour), static_cast<int> (i.minute), - static_cast<int> (i.second))); + static_cast<int> (i.second), + static_cast<int> (i.second_part / 1000))); } static void @@ -61,8 +64,7 @@ namespace odb i.hour = static_cast<unsigned int> (t.hour ()); i.minute = static_cast<unsigned int> (t.minute ()); i.second = static_cast<unsigned int> (t.second ()); - - i.second_part = 0; + i.second_part = static_cast<unsigned long> (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<int> (i.year), static_cast<int> (i.month), static_cast<int> (i.day)), QTime (static_cast<int> (i.hour), static_cast<int> (i.minute), - static_cast<int> (i.second))); + static_cast<int> (i.second), + static_cast<int> (i.second_part / 1000))); } static void @@ -113,8 +118,7 @@ namespace odb i.hour = static_cast<unsigned int> (t.hour ()); i.minute = static_cast<unsigned int> (t.minute ()); i.second = static_cast<unsigned int> (t.second ()); - - i.second_part = 0; + i.second_part = static_cast<unsigned long> (t.msec ()) * 1000; } } }; |