aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/qt/date-time/mssql/qdate-time-traits.hxx38
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;
+ }
}
}
};