diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-30 14:56:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-30 14:56:36 +0200 |
commit | 03529d414dd9afc3994995f1fdfb9df3c6d53826 (patch) | |
tree | 3247ad412a58bd9d7163f5fc59a5c516f8691642 | |
parent | 1e92096fab12cd85bc8d096243da11381a97a119 (diff) |
Handle SMALLDATETIME case in SQL Server QDateTime traits implementation1.8.0
-rw-r--r-- | odb/qt/date-time/mssql/qdate-time-traits.hxx | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/odb/qt/date-time/mssql/qdate-time-traits.hxx b/odb/qt/date-time/mssql/qdate-time-traits.hxx index f64906e..8d421d6 100644 --- a/odb/qt/date-time/mssql/qdate-time-traits.hxx +++ b/odb/qt/date-time/mssql/qdate-time-traits.hxx @@ -60,22 +60,34 @@ namespace odb i.day = static_cast<SQLUSMALLINT> (d.day ()); i.hour = static_cast<SQLUSMALLINT> (t.hour ()); i.minute = static_cast<SQLUSMALLINT> (t.minute ()); - i.second = static_cast<SQLUSMALLINT> (t.second ()); - const unsigned int divider[8] = + // Scale value 8 indicates we are dealing with SMALLDATETIME + // which has the minutes precision. + // + if (s != 8) { - 1000000000, - 100000000, - 10000000, - 1000000, - 100000, - 10000, - 1000, - 100 - }; + i.second = static_cast<SQLUSMALLINT> (t.second ()); + + const unsigned int divider[8] = + { + 1000000000, + 100000000, + 10000000, + 1000000, + 100000, + 10000, + 1000, + 100 + }; - unsigned int ns (static_cast<unsigned int> (t.msec ()) * 1000000); - i.fraction = static_cast<SQLUINTEGER> (ns - ns % divider[s]); + unsigned int ns (static_cast<unsigned int> (t.msec ()) * 1000000); + i.fraction = static_cast<SQLUINTEGER> (ns - ns % divider[s]); + } + else + { + i.second = 0; + i.fraction = 0; + } } } }; |