aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-07-03 11:57:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-07-03 11:58:03 +0200
commit1e4a0de189cab11858c977961b884872728abaf0 (patch)
tree1e12ab12f4c8a31d8780c0ebefb4d8af131e6f32
parentc79ec4a52b71135a2cdd3a97560a46f461334482 (diff)
Add support for sub-seconds in MySQL
-rw-r--r--odb/qt/date-time/mysql/qdate-time-traits.hxx16
-rw-r--r--odb/qt/date-time/mysql/qtime-traits.hxx8
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<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;
}
}
};
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<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
@@ -54,8 +57,7 @@ namespace odb
i.hour = static_cast<unsigned int> (v.hour ());
i.minute = static_cast<unsigned int> (v.minute ());
i.second = static_cast<unsigned int> (v.second ());
-
- i.second_part = 0;
+ i.second_part = static_cast<unsigned long> (v.msec ()) * 1000;
}
}
};