You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/03/21 08:48:20 UTC

ignite git commit: GNITE-2747: ODBC: Fixed time cast issues. This closes #536.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1786 40beea346 -> 06a3e9178


GNITE-2747: ODBC: Fixed time cast issues. This closes #536.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/06a3e917
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/06a3e917
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/06a3e917

Branch: refs/heads/ignite-1786
Commit: 06a3e91782dd00ddada54be031cb7f2a79e4a10a
Parents: 40beea3
Author: isapego <is...@gridgain.com>
Authored: Mon Mar 21 10:48:13 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Mar 21 10:48:13 2016 +0300

----------------------------------------------------------------------
 .../include/ignite/impl/binary/binary_utils.h   | 170 +++++++++-
 .../cpp/binary/src/impl/binary/binary_utils.cpp |  68 +++-
 .../cpp/common/include/ignite/common/utils.h    |  34 ++
 .../platforms/cpp/common/os/linux/src/utils.cpp |  24 ++
 .../platforms/cpp/common/os/win/src/utils.cpp   |  26 ++
 .../cpp/core-test/src/cache_query_test.cpp      | 334 ++++++++++++++-----
 .../src/application_data_buffer_test.cpp        | 122 +++----
 .../cpp/odbc-test/src/queries_test.cpp          |  22 +-
 .../platforms/cpp/odbc/include/ignite/odbc.h    |   1 -
 .../cpp/odbc/include/ignite/odbc/utility.h      |  16 +-
 .../odbc/src/app/application_data_buffer.cpp    |  66 ++--
 modules/platforms/cpp/odbc/src/utility.cpp      |  10 -
 12 files changed, 690 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
index fde3353..403d534 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
@@ -20,6 +20,8 @@
 
 #include <stdint.h>
 
+#include "ignite/common/utils.h"
+
 #include "ignite/guid.h"
 #include "ignite/date.h"
 #include "ignite/timestamp.h"
@@ -370,9 +372,175 @@ namespace ignite
                  * @param len Length.
                  */
                 static void WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len);
+
+                /**
+                 * Convert Date type to standard C type time_t.
+                 *
+                 * @param date Date type value.
+                 * @return Corresponding value of time_t.
+                 */
+                static inline time_t DateToCTime(const Date& date)
+                {
+                    return static_cast<time_t>(date.GetSeconds());
+                }
+
+                /**
+                 * Convert Timestamp type to standard C type time_t.
+                 *
+                 * @param ts Timestamp type value.
+                 * @return Corresponding value of time_t.
+                 */
+                static inline time_t TimestampToCTime(const Timestamp& ts)
+                {
+                    return static_cast<time_t>(ts.GetSeconds());
+                }
+
+                /**
+                 * Convert Date type to standard C type time_t.
+                 *
+                 * @param date Date type value.
+                 * @param ctime Corresponding value of struct tm.
+                 * @return True on success.
+                 */
+                static inline bool DateToCTm(const Date& date, tm& ctime)
+                {
+                    time_t tmt = DateToCTime(date);
+
+                    return common::utils::IgniteGmTime(tmt, ctime);
+                }
+
+                /**
+                 * Convert Timestamp type to standard C type struct tm.
+                 *
+                 * @param ts Timestamp type value.
+                 * @param ctime Corresponding value of struct tm.
+                 * @return True on success.
+                 */
+                static inline bool TimestampToCTm(const Timestamp& ts, tm& ctime)
+                {
+                    time_t tmt = TimestampToCTime(ts);
+
+                    return common::utils::IgniteGmTime(tmt, ctime);
+                }
+
+                /**
+                 * Convert standard C type time_t to Date struct tm.
+                 *
+                 * @param ctime Standard C type time_t.
+                 * @return Corresponding value of Date.
+                 */
+                static inline Date CTimeToDate(time_t ctime)
+                {
+                    return Date(ctime * 1000);
+                }
+
+                /**
+                 * Convert standard C type time_t to Timestamp type.
+                 *
+                 * @param ctime Standard C type time_t.
+                 * @param ns Nanoseconds second fraction.
+                 * @return Corresponding value of Timestamp.
+                 */
+                static inline Timestamp CTimeToTimestamp(time_t ctime, int32_t ns)
+                {
+                    return Timestamp(ctime, ns);
+                }
+
+                /**
+                 * Convert standard C type struct tm to Date type.
+                 *
+                 * @param ctime Standard C type struct tm.
+                 * @return Corresponding value of Date.
+                 */
+                static inline Date CTmToDate(const tm& ctime)
+                {
+                    time_t time = common::utils::IgniteTimeGm(ctime);
+
+                    return CTimeToDate(time);
+                }
+
+                /**
+                 * Convert standard C type struct tm to Timestamp type.
+                 *
+                 * @param ctime Standard C type struct tm.
+                 * @param ns Nanoseconds second fraction.
+                 * @return Corresponding value of Timestamp.
+                 */
+                static inline Timestamp CTmToTimestamp(const tm& ctime, int32_t ns)
+                {
+                    time_t time = common::utils::IgniteTimeGm(ctime);
+
+                    return CTimeToTimestamp(time, ns);
+                }
+
+                /**
+                 * Make Date in human understandable way.
+                 *
+                 * Created Date uses GMT timezone.
+                 *
+                 * @param year Year.
+                 * @param month Month.
+                 * @param day Day.
+                 * @param hour Hour.
+                 * @param min Min.
+                 * @param sec Sec.
+                 * @return Date.
+                 */
+                static Date MakeDateGmt(int year = 1900, int month = 1,
+                    int day = 1, int hour = 0, int min = 0, int sec = 0);
+
+                /**
+                 * Make Date in human understandable way.
+                 *
+                 * Created Date uses local timezone.
+                 *
+                 * @param year Year.
+                 * @param month Month.
+                 * @param day Day.
+                 * @param hour Hour.
+                 * @param min Min.
+                 * @param sec Sec.
+                 * @return Date.
+                 */
+                static Date MakeDateLocal(int year = 1900, int month = 1,
+                    int day = 1, int hour = 0, int min = 0, int sec = 0);
+
+                /**
+                 * Make Date in human understandable way.
+                 *
+                 * Created Timestamp uses GMT timezone.
+                 *
+                 * @param year Year.
+                 * @param month Month.
+                 * @param day Day.
+                 * @param hour Hour.
+                 * @param min Minute.
+                 * @param sec Second.
+                 * @param ns Nanosecond.
+                 * @return Timestamp.
+                 */
+                static Timestamp MakeTimestampGmt(int year = 1900, int month = 1,
+                    int day = 1, int hour = 0, int min = 0, int sec = 0, long ns = 0);
+
+                /**
+                 * Make Date in human understandable way.
+                 *
+                 * Created Timestamp uses Local timezone.
+                 *
+                 * @param year Year.
+                 * @param month Month.
+                 * @param day Day.
+                 * @param hour Hour.
+                 * @param min Minute.
+                 * @param sec Second.
+                 * @param ns Nanosecond.
+                 * @return Timestamp.
+                 */
+                static Timestamp MakeTimestampLocal(int year = 1900, int month = 1,
+                    int day = 1, int hour = 0, int min = 0, int sec = 0, long ns = 0);
             };
         }
     }
 }
 
-#endif
\ No newline at end of file
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
index bfb9726..dc876ef 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+#include <time.h>
+
 #include "ignite/impl/interop/interop.h"
 #include "ignite/impl/binary/binary_utils.h"
 
@@ -232,6 +234,70 @@ namespace ignite
                 stream->WriteInt32(len);
                 stream->WriteInt8Array(reinterpret_cast<const int8_t*>(val), len);
             }
+
+            Date BinaryUtils::MakeDateGmt(int year, int month, int day, int hour,
+                int min, int sec)
+            {
+                tm date = { 0 };
+
+                date.tm_year = year - 1900;
+                date.tm_mon = month - 1;
+                date.tm_mday = day;
+                date.tm_hour = hour;
+                date.tm_min = min;
+                date.tm_sec = sec;
+
+                return CTmToDate(date);
+            }
+
+            Date BinaryUtils::MakeDateLocal(int year, int month, int day, int hour,
+                int min, int sec)
+            {
+                tm date = { 0 };
+
+                date.tm_year = year - 1900;
+                date.tm_mon = month - 1;
+                date.tm_mday = day;
+                date.tm_hour = hour;
+                date.tm_min = min;
+                date.tm_sec = sec;
+
+                time_t localTime = common::utils::IgniteTimeLocal(date);
+
+                return CTimeToDate(localTime);
+            }
+
+            Timestamp BinaryUtils::MakeTimestampGmt(int year, int month, int day,
+                int hour, int min, int sec, long ns)
+            {
+                tm date = { 0 };
+
+                date.tm_year = year - 1900;
+                date.tm_mon = month - 1;
+                date.tm_mday = day;
+                date.tm_hour = hour;
+                date.tm_min = min;
+                date.tm_sec = sec;
+
+                return CTmToTimestamp(date, ns);
+            }
+
+            Timestamp BinaryUtils::MakeTimestampLocal(int year, int month, int day,
+                int hour, int min, int sec, long ns)
+            {
+                tm date = { 0 };
+
+                date.tm_year = year - 1900;
+                date.tm_mon = month - 1;
+                date.tm_mday = day;
+                date.tm_hour = hour;
+                date.tm_min = min;
+                date.tm_sec = sec;
+
+                time_t localTime = common::utils::IgniteTimeLocal(date);
+
+                return CTimeToTimestamp(localTime, ns);
+            }
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index 05f3595..06d7c56 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -86,6 +86,40 @@ namespace ignite
             }
 
             /**
+             * Convert struct tm to time_t (UTC).
+             *
+             * @param time Standard C type struct tm value.
+             * @return Standard C type time_t value.
+             */
+            IGNITE_IMPORT_EXPORT time_t IgniteTimeGm(const tm& time);
+
+            /**
+             * Convert struct tm to time_t (Local time).
+             *
+             * @param time Standard C type struct tm value.
+             * @return Standard C type time_t value.
+             */
+            IGNITE_IMPORT_EXPORT time_t IgniteTimeLocal(const tm& time);
+
+            /**
+             * Convert time_t to struct tm (UTC).
+             *
+             * @param in Standard C type time_t value.
+             * @param out Standard C type struct tm value.
+             * @return True on success.
+             */
+            IGNITE_IMPORT_EXPORT bool IgniteGmTime(time_t in, tm& out);
+
+            /**
+             * Convert time_t to struct tm (Local time).
+             *
+             * @param in Standard C type time_t value.
+             * @param out Standard C type struct tm value.
+             * @return True on success.
+             */
+            IGNITE_IMPORT_EXPORT bool IgniteLocalTime(time_t in, tm& out);
+
+            /**
              * Get number of leading zeroes in octet.
              *
              * @param octet Octet.

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/common/os/linux/src/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/src/utils.cpp b/modules/platforms/cpp/common/os/linux/src/utils.cpp
index 5c6df36..534786f 100644
--- a/modules/platforms/cpp/common/os/linux/src/utils.cpp
+++ b/modules/platforms/cpp/common/os/linux/src/utils.cpp
@@ -296,6 +296,30 @@ namespace ignite
                 return res;
             }
 
+            time_t IgniteTimeGm(const tm& time)
+            {
+                tm tmc = time;
+
+                return timegm(&tmc);
+            }
+
+            time_t IgniteTimeLocal(const tm& time)
+            {
+                tm tmc = time;
+
+                return mktime(&tmc);
+            }
+
+            bool IgniteGmTime(time_t in, tm& out)
+            {
+                return gmtime_r(&in, &out) != NULL;
+            }
+
+            bool IgniteLocalTime(time_t in, tm& out)
+            {
+                return localtime_r(&in, &out) == 0;
+            }
+
             int LeadingZeroesForOctet(int8_t octet) {
                 if (octet == 0)
                     return 8;

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/common/os/win/src/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/utils.cpp b/modules/platforms/cpp/common/os/win/src/utils.cpp
index 2f28645..13aede3 100644
--- a/modules/platforms/cpp/common/os/win/src/utils.cpp
+++ b/modules/platforms/cpp/common/os/win/src/utils.cpp
@@ -17,6 +17,8 @@
 
 #include <windows.h>
 
+#include <time.h>
+
 #include <ignite/common/utils.h>
 
 namespace ignite
@@ -290,6 +292,30 @@ namespace ignite
                 return res;
             }
 
+            time_t IgniteTimeGm(const tm& time)
+            {
+                tm tmc = time;
+
+                return _mkgmtime(&tmc);
+            }
+
+            time_t IgniteTimeLocal(const tm& time)
+            {
+                tm tmc = time;
+
+                return mktime(&tmc);
+            }
+
+            bool IgniteGmTime(time_t in, tm& out)
+            {
+                return gmtime_s(&out, &in) == 0;
+            }
+
+            bool IgniteLocalTime(time_t in, tm& out)
+            {
+                return localtime_s(&out, &in) == 0;
+            }
+
             int LeadingZeroesForOctet(int8_t octet) {
                 if (octet == 0)
                     return 8;

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index a22ddad..f989f7b 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -40,6 +40,8 @@ using namespace ignite::cache;
 using namespace ignite::cache::query;
 using namespace ignite::common::utils;
 
+using ignite::impl::binary::BinaryUtils;
+
 /**
  * Person class for query tests.
  */
@@ -520,61 +522,6 @@ void CheckMultipleGetAll(Cursor& cur, int key1, const std::string& name1,
     }
 }
 
-/**
- * Make Date in human understandable way.
- *
- * @param year Year.
- * @param month Month.
- * @param day Day.
- * @param hour Hour.
- * @param min Min.
- * @param sec Sec.
- * @return Date.
- */
-Date MakeDate(int year = 1900, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0)
-{
-    tm date;
-
-    date.tm_year = year - 1900;
-    date.tm_mon = month - 1;
-    date.tm_mday = day;
-    date.tm_hour = hour;
-    date.tm_min = min;
-    date.tm_sec = sec;
-
-    time_t ct = mktime(&date);
-
-    return Date(ct * 1000);
-}
-
-/**
- * Make Date in human understandable way.
- *
- * @param year Year.
- * @param month Month.
- * @param day Day.
- * @param hour Hour.
- * @param min Minute.
- * @param sec Second.
- * @param ns Nanosecond.
- * @return Timestamp.
- */
-Timestamp MakeTimestamp(int year = 1900, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0, long ns = 0)
-{
-    tm date;
-
-    date.tm_year = year - 1900;
-    date.tm_mon = month - 1;
-    date.tm_mday = day;
-    date.tm_hour = hour;
-    date.tm_min = min;
-    date.tm_sec = sec;
-
-    time_t ct = mktime(&date);
-
-    return Timestamp(ct, ns);
-}
-
 BOOST_FIXTURE_TEST_SUITE(CacheQueryTestSuite, CacheQueryTestSuiteFixture)
 
 /**
@@ -594,8 +541,8 @@ BOOST_AUTO_TEST_CASE(TestSqlQuery)
     CheckEmptyGetAll(cursor);
 
     // Test simple query.
-    cache.Put(1, QueryPerson("A1", 10, MakeDate(1990, 03, 18), MakeTimestamp(2016, 02, 10, 17, 39, 34, 579304685)));
-    cache.Put(2, QueryPerson("A2", 20, MakeDate(1989, 10, 26), MakeTimestamp(2016, 02, 10, 17, 39, 35, 678403201)));
+    cache.Put(1, QueryPerson("A1", 10, BinaryUtils::MakeDateLocal(1990, 03, 18), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 34, 579304685)));
+    cache.Put(2, QueryPerson("A2", 20, BinaryUtils::MakeDateLocal(1989, 10, 26), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 35, 678403201)));
     
     cursor = cache.Query(qry);
     CheckSingle(cursor, 1, "A1", 10);
@@ -650,8 +597,8 @@ BOOST_AUTO_TEST_CASE(TestTextQuery)
     CheckEmptyGetAll(cursor);
 
     // Test simple query.
-    cache.Put(1, QueryPerson("A1", 10, MakeDate(1990, 03, 18), MakeTimestamp(2016, 02, 10, 17, 39, 34, 579304685)));
-    cache.Put(2, QueryPerson("A2", 20, MakeDate(1989, 10, 26), MakeTimestamp(2016, 02, 10, 17, 39, 35, 678403201)));
+    cache.Put(1, QueryPerson("A1", 10, BinaryUtils::MakeDateLocal(1990, 03, 18), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 34, 579304685)));
+    cache.Put(2, QueryPerson("A2", 20, BinaryUtils::MakeDateLocal(1989, 10, 26), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 35, 678403201)));
 
     cursor = cache.Query(qry);
     CheckSingle(cursor, 1, "A1", 10);
@@ -696,7 +643,7 @@ BOOST_AUTO_TEST_CASE(TestScanQuery)
     CheckEmptyGetAll(cursor);
 
     // Test simple query.
-    cache.Put(1, QueryPerson("A1", 10, MakeDate(1990, 03, 18), MakeTimestamp(2016, 02, 10, 17, 39, 34, 579304685)));
+    cache.Put(1, QueryPerson("A1", 10, BinaryUtils::MakeDateLocal(1990, 03, 18), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 34, 579304685)));
 
     cursor = cache.Query(qry);
     CheckSingle(cursor, 1, "A1", 10);
@@ -705,7 +652,7 @@ BOOST_AUTO_TEST_CASE(TestScanQuery)
     CheckSingleGetAll(cursor, 1, "A1", 10);
 
     // Test query returning multiple entries.
-    cache.Put(2, QueryPerson("A2", 20, MakeDate(1989, 10, 26), MakeTimestamp(2016, 02, 10, 17, 39, 35, 678403201)));
+    cache.Put(2, QueryPerson("A2", 20, BinaryUtils::MakeDateLocal(1989, 10, 26), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 35, 678403201)));
 
     cursor = cache.Query(qry);
     CheckMultiple(cursor, 1, "A1", 10, 2, "A2", 20);
@@ -731,7 +678,7 @@ BOOST_AUTO_TEST_CASE(TestScanQueryPartitioned)
 
         stream << "A" << i;
 
-        cache.Put(i, QueryPerson(stream.str(), i * 10, MakeDate(1970 + i), MakeTimestamp(2016, 1, 1, i / 60, i % 60)));
+        cache.Put(i, QueryPerson(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1970 + i), BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60)));
     }
 
     // Iterate over all partitions and collect data.
@@ -778,7 +725,7 @@ BOOST_AUTO_TEST_CASE(TestFieldsQuerySingle)
     CheckEmpty(cursor);
     
     // Test simple query.
-    cache.Put(1, QueryPerson("A1", 10, MakeDate(1990, 03, 18), MakeTimestamp(2016, 02, 10, 17, 39, 34, 579304685)));
+    cache.Put(1, QueryPerson("A1", 10, BinaryUtils::MakeDateLocal(1990, 03, 18), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 34, 579304685)));
 
     cursor = cache.Query(qry);
 
@@ -823,7 +770,7 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryExceptions)
     CheckEmpty(cursor);
 
     // Test simple query.
-    cache.Put(1, QueryPerson("A1", 10, MakeDate(1990, 03, 18), MakeTimestamp(2016, 02, 10, 17, 39, 34, 579304685)));
+    cache.Put(1, QueryPerson("A1", 10, BinaryUtils::MakeDateLocal(1990, 03, 18), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 34, 579304685)));
 
     cursor = cache.Query(qry);
 
@@ -868,8 +815,8 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryTwo)
     CheckEmpty(cursor);
 
     // Test simple query.
-    cache.Put(1, QueryPerson("A1", 10, MakeDate(1990, 03, 18), MakeTimestamp(2016, 02, 10, 17, 39, 34, 579304685)));
-    cache.Put(2, QueryPerson("A2", 20, MakeDate(1989, 10, 26), MakeTimestamp(2016, 02, 10, 17, 39, 35, 678403201)));
+    cache.Put(1, QueryPerson("A1", 10, BinaryUtils::MakeDateLocal(1990, 03, 18), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 34, 579304685)));
+    cache.Put(2, QueryPerson("A2", 20, BinaryUtils::MakeDateLocal(1989, 10, 26), BinaryUtils::MakeTimestampLocal(2016, 02, 10, 17, 39, 35, 678403201)));
 
     cursor = cache.Query(qry);
 
@@ -938,7 +885,10 @@ BOOST_AUTO_TEST_CASE(TestFieldsQuerySeveral)
 
         stream << "A" << i;
 
-        cache.Put(i, QueryPerson(stream.str(), i * 10, MakeDate(1970 + i), MakeTimestamp(2016, 1, 1, i / 60, i % 60)));
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
     }
 
     cursor = cache.Query(qry);
@@ -982,7 +932,7 @@ BOOST_AUTO_TEST_CASE(TestFieldsQuerySeveral)
 /**
  * Test query for Date type.
  */
-BOOST_AUTO_TEST_CASE(TestFieldsQueryDate)
+BOOST_AUTO_TEST_CASE(TestFieldsQueryDateLess)
 {
     // Test simple query.
     Cache<int, QueryPerson> cache = GetCache();
@@ -1001,7 +951,10 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryDate)
 
         stream << "A" << i;
 
-        cache.Put(i, QueryPerson(stream.str(), i * 10, MakeDate(1980 + i), MakeTimestamp(2016, 1, 1, i / 60, i % 60)));
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
     }
 
     cursor = cache.Query(qry);
@@ -1023,9 +976,9 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryDate)
         Date birthday = row.GetNext<Date>(error);
         BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
 
-        BOOST_CHECK(birthday == MakeDate(1980 + resultSetSize));
+        BOOST_CHECK(birthday == BinaryUtils::MakeDateLocal(1980 + resultSetSize, 1, 1));
 
-        BOOST_CHECK(birthday < MakeDate(1990, 1, 1));
+        BOOST_CHECK(birthday < BinaryUtils::MakeDateLocal(1990, 1, 1));
 
         BOOST_REQUIRE(!row.HasNext());
 
@@ -1038,9 +991,122 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryDate)
 }
 
 /**
+ * Test query for Date type.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryDateMore)
+{
+    // Test simple query.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with field of type 'Date'.
+    SqlFieldsQuery qry("select birthday from QueryPerson where birthday>'2070-01-01'");
+
+    QueryFieldsCursor cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    int32_t entryCnt = 100; // Number of entries.
+
+    for (int i = 0; i < entryCnt; i++)
+    {
+        std::stringstream stream;
+
+        stream << "A" << i;
+
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
+    }
+
+    cursor = cache.Query(qry);
+
+    IgniteError error;
+
+    int32_t resultSetSize = 0; // Number of entries in query result set.
+
+    while (cursor.HasNext(error))
+    {
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        QueryFieldsRow row = cursor.GetNext(error);
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        BOOST_REQUIRE(row.HasNext(error));
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        Date birthday = row.GetNext<Date>(error);
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        BOOST_CHECK(birthday == BinaryUtils::MakeDateLocal(2071 + resultSetSize, 1, 1));
+
+        BOOST_CHECK(birthday > BinaryUtils::MakeDateLocal(2070, 1, 1));
+
+        BOOST_REQUIRE(!row.HasNext());
+
+        ++resultSetSize;
+    }
+
+    BOOST_CHECK_EQUAL(resultSetSize, 9);
+
+    CheckEmpty(cursor);
+}
+
+/**
+ * Test query for Date type.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryDateEqual)
+{
+    // Test simple query.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with field of type 'Date'.
+    SqlFieldsQuery qry("select birthday from QueryPerson where birthday='2032-01-01'");
+
+    QueryFieldsCursor cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    int32_t entryCnt = 100; // Number of entries.
+
+    for (int i = 0; i < entryCnt; i++)
+    {
+        std::stringstream stream;
+
+        stream << "A" << i;
+
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
+    }
+
+    cursor = cache.Query(qry);
+
+    IgniteError error;
+
+    BOOST_REQUIRE(cursor.HasNext(error));
+
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    QueryFieldsRow row = cursor.GetNext(error);
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    BOOST_REQUIRE(row.HasNext(error));
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    Date birthday = row.GetNext<Date>(error);
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    BOOST_CHECK(birthday == BinaryUtils::MakeDateLocal(2032, 1, 1));
+
+    BOOST_REQUIRE(!row.HasNext());
+
+    CheckEmpty(cursor);
+}
+
+/**
  * Test query for Timestamp type.
  */
-BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestamp)
+BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestampLess)
 {
     // Test simple query.
     Cache<int, QueryPerson> cache = GetCache();
@@ -1059,7 +1125,10 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestamp)
 
         stream << "A" << i;
 
-        cache.Put(i, QueryPerson(stream.str(), i * 10, MakeDate(1980 + i), MakeTimestamp(2016, 1, 1, i / 60, i % 60)));
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
     }
 
     cursor = cache.Query(qry);
@@ -1081,9 +1150,9 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestamp)
         Timestamp recordCreated = row.GetNext<Timestamp>(error);
         BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
 
-        BOOST_CHECK(recordCreated == MakeTimestamp(2016, 1, 1, 0, resultSetSize % 60, 0));
+        BOOST_CHECK(recordCreated == BinaryUtils::MakeTimestampLocal(2016, 1, 1, 0, resultSetSize % 60, 0));
 
-        BOOST_CHECK(recordCreated < MakeTimestamp(2016, 1, 1, 1, 0, 0));
+        BOOST_CHECK(recordCreated < BinaryUtils::MakeTimestampLocal(2016, 1, 1, 1, 0, 0));
 
         BOOST_REQUIRE(!row.HasNext());
 
@@ -1095,4 +1164,119 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestamp)
     CheckEmpty(cursor);
 }
 
+/**
+ * Test query for Timestamp type.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestampMore)
+{
+    // Test simple query.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with field of type 'Timestamp'.
+    SqlFieldsQuery qry("select recordCreated from QueryPerson where recordCreated>'2016-01-01 15:30:00'");
+
+    QueryFieldsCursor cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    int32_t entryCnt = 1000; // Number of entries.
+
+    for (int i = 0; i < entryCnt; i++)
+    {
+        std::stringstream stream;
+
+        stream << "A" << i;
+
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
+    }
+
+    cursor = cache.Query(qry);
+
+    IgniteError error;
+
+    int32_t resultSetSize = 0; // Number of entries in query result set.
+
+    while (cursor.HasNext(error))
+    {
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        QueryFieldsRow row = cursor.GetNext(error);
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        BOOST_REQUIRE(row.HasNext(error));
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        Timestamp recordCreated = row.GetNext<Timestamp>(error);
+        BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+        int32_t minutes = resultSetSize + 31;
+
+        BOOST_CHECK(recordCreated == BinaryUtils::MakeTimestampLocal(2016, 1, 1, 15 + minutes / 60, minutes % 60, 0));
+
+        BOOST_CHECK(recordCreated > BinaryUtils::MakeTimestampLocal(2016, 1, 1, 15, 30, 0));
+
+        BOOST_REQUIRE(!row.HasNext());
+
+        ++resultSetSize;
+    }
+
+    BOOST_CHECK_EQUAL(resultSetSize, 69);
+
+    CheckEmpty(cursor);
+}
+
+/**
+ * Test query for Timestamp type.
+ */
+BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestampEqual)
+{
+    // Test simple query.
+    Cache<int, QueryPerson> cache = GetCache();
+
+    // Test query with field of type 'Timestamp'.
+    SqlFieldsQuery qry("select recordCreated from QueryPerson where recordCreated='2016-01-01 09:18:00'");
+
+    QueryFieldsCursor cursor = cache.Query(qry);
+    CheckEmpty(cursor);
+
+    int32_t entryCnt = 1000; // Number of entries.
+
+    for (int i = 0; i < entryCnt; i++)
+    {
+        std::stringstream stream;
+
+        stream << "A" << i;
+
+        QueryPerson val(stream.str(), i * 10, BinaryUtils::MakeDateLocal(1980 + i, 1, 1),
+            BinaryUtils::MakeTimestampLocal(2016, 1, 1, i / 60, i % 60));
+
+        cache.Put(i, val);
+    }
+
+    cursor = cache.Query(qry);
+
+    IgniteError error;
+
+    BOOST_REQUIRE(cursor.HasNext(error));
+
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    QueryFieldsRow row = cursor.GetNext(error);
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    BOOST_REQUIRE(row.HasNext(error));
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    Timestamp recordCreated = row.GetNext<Timestamp>(error);
+    BOOST_REQUIRE(error.GetCode() == IgniteError::IGNITE_SUCCESS);
+
+    BOOST_CHECK(recordCreated == BinaryUtils::MakeTimestampLocal(2016, 1, 1, 9, 18, 0));
+
+    BOOST_REQUIRE(!row.HasNext());
+
+    CheckEmpty(cursor);
+}
+
 BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
index 1eac1de..8b128f7 100644
--- a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
@@ -37,7 +37,7 @@ using namespace ignite::odbc;
 using namespace ignite::odbc::app;
 using namespace ignite::odbc::type_traits;
 
-using namespace test_utils;
+using ignite::impl::binary::BinaryUtils;
 
 BOOST_AUTO_TEST_SUITE(ApplicationDataBufferTestSuite)
 
@@ -407,7 +407,7 @@ BOOST_AUTO_TEST_CASE(TestPutDateToString)
 
     ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
 
-    Date date = MakeDate(1999, 2, 22);
+    Date date = BinaryUtils::MakeDateGmt(1999, 2, 22);
 
     appBuf.PutDate(date);
 
@@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(TestPutTimestampToString)
 
     ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
 
-    Timestamp date = MakeTimestamp(2018, 11, 1, 17, 45, 59);
+    Timestamp date = BinaryUtils::MakeTimestampGmt(2018, 11, 1, 17, 45, 59);
 
     appBuf.PutTimestamp(date);
 
@@ -438,7 +438,7 @@ BOOST_AUTO_TEST_CASE(TestPutDateToDate)
 
     ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr);
 
-    Date date = MakeDate(1984, 5, 27);
+    Date date = BinaryUtils::MakeDateGmt(1984, 5, 27);
 
     appBuf.PutDate(date);
 
@@ -457,7 +457,7 @@ BOOST_AUTO_TEST_CASE(TestPutTimestampToDate)
 
     ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr);
 
-    Timestamp ts = MakeTimestamp(2004, 8, 14, 6, 34, 51, 573948623);
+    Timestamp ts = BinaryUtils::MakeTimestampGmt(2004, 8, 14, 6, 34, 51, 573948623);
 
     appBuf.PutTimestamp(ts);
 
@@ -476,7 +476,7 @@ BOOST_AUTO_TEST_CASE(TestPutTimestampToTimestamp)
 
     ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr);
 
-    Timestamp ts = MakeTimestamp(2004, 8, 14, 6, 34, 51, 573948623);
+    Timestamp ts = BinaryUtils::MakeTimestampGmt(2004, 8, 14, 6, 34, 51, 573948623);
 
     appBuf.PutTimestamp(ts);
 
@@ -500,7 +500,7 @@ BOOST_AUTO_TEST_CASE(TestPutDateToTimestamp)
 
     ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr);
 
-    Date date = MakeDate(1984, 5, 27);
+    Date date = BinaryUtils::MakeDateGmt(1984, 5, 27);
 
     appBuf.PutDate(date);
 
@@ -822,18 +822,18 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromString)
 
     Date date = appBuf.GetDate();
 
-    time_t cTime = utility::DateToCTime(date);
+    tm tmDate;
 
-    tm *tmDate = std::gmtime(&cTime);
+    bool success = BinaryUtils::DateToCTm(date, tmDate);
 
-    BOOST_REQUIRE(tmDate != 0);
+    BOOST_REQUIRE(success);
 
-    BOOST_CHECK_EQUAL(1999, tmDate->tm_year + 1900);
-    BOOST_CHECK_EQUAL(2, tmDate->tm_mon + 1);
-    BOOST_CHECK_EQUAL(22, tmDate->tm_mday);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_hour);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_min);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_sec);
+    BOOST_CHECK_EQUAL(1999, tmDate.tm_year + 1900);
+    BOOST_CHECK_EQUAL(2, tmDate.tm_mon + 1);
+    BOOST_CHECK_EQUAL(22, tmDate.tm_mday);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_hour);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_min);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_sec);
 }
 
 BOOST_AUTO_TEST_CASE(TestGetTimestampFromString)
@@ -853,18 +853,18 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromString)
 
     Timestamp date = appBuf.GetTimestamp();
 
-    time_t cTime = utility::TimestampToCTime(date);
+    tm tmDate;
 
-    tm *tmDate = std::gmtime(&cTime);
+    bool success = BinaryUtils::TimestampToCTm(date, tmDate);
 
-    BOOST_REQUIRE(tmDate != 0);
+    BOOST_REQUIRE(success);
 
-    BOOST_CHECK_EQUAL(2018, tmDate->tm_year + 1900);
-    BOOST_CHECK_EQUAL(11, tmDate->tm_mon + 1);
-    BOOST_CHECK_EQUAL(1, tmDate->tm_mday);
-    BOOST_CHECK_EQUAL(17, tmDate->tm_hour);
-    BOOST_CHECK_EQUAL(45, tmDate->tm_min);
-    BOOST_CHECK_EQUAL(59, tmDate->tm_sec);
+    BOOST_CHECK_EQUAL(2018, tmDate.tm_year + 1900);
+    BOOST_CHECK_EQUAL(11, tmDate.tm_mon + 1);
+    BOOST_CHECK_EQUAL(1, tmDate.tm_mday);
+    BOOST_CHECK_EQUAL(17, tmDate.tm_hour);
+    BOOST_CHECK_EQUAL(45, tmDate.tm_min);
+    BOOST_CHECK_EQUAL(59, tmDate.tm_sec);
 }
 
 BOOST_AUTO_TEST_CASE(TestGetDateFromDate)
@@ -884,18 +884,18 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromDate)
 
     Date date = appBuf.GetDate();
 
-    time_t cTime = utility::DateToCTime(date);
+    tm tmDate;
 
-    tm *tmDate = std::gmtime(&cTime);
+    bool success = BinaryUtils::DateToCTm(date, tmDate);
 
-    BOOST_REQUIRE(tmDate != 0);
+    BOOST_REQUIRE(success);
 
-    BOOST_CHECK_EQUAL(1984, tmDate->tm_year + 1900);
-    BOOST_CHECK_EQUAL(5, tmDate->tm_mon + 1);
-    BOOST_CHECK_EQUAL(27, tmDate->tm_mday);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_hour);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_min);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_sec);
+    BOOST_CHECK_EQUAL(1984, tmDate.tm_year + 1900);
+    BOOST_CHECK_EQUAL(5, tmDate.tm_mon + 1);
+    BOOST_CHECK_EQUAL(27, tmDate.tm_mday);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_hour);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_min);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_sec);
 }
 
 BOOST_AUTO_TEST_CASE(TestGetTimestampFromDate)
@@ -915,18 +915,18 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromDate)
 
     Timestamp ts = appBuf.GetTimestamp();
 
-    time_t cTime = utility::TimestampToCTime(ts);
+    tm tmDate;
 
-    tm *tmDate = std::gmtime(&cTime);
+    bool success = BinaryUtils::TimestampToCTm(ts, tmDate);
 
-    BOOST_REQUIRE(tmDate != 0);
+    BOOST_REQUIRE(success);
 
-    BOOST_CHECK_EQUAL(1984, tmDate->tm_year + 1900);
-    BOOST_CHECK_EQUAL(5, tmDate->tm_mon + 1);
-    BOOST_CHECK_EQUAL(27, tmDate->tm_mday);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_hour);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_min);
-    BOOST_CHECK_EQUAL(0, tmDate->tm_sec);
+    BOOST_CHECK_EQUAL(1984, tmDate.tm_year + 1900);
+    BOOST_CHECK_EQUAL(5, tmDate.tm_mon + 1);
+    BOOST_CHECK_EQUAL(27, tmDate.tm_mday);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_hour);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_min);
+    BOOST_CHECK_EQUAL(0, tmDate.tm_sec);
 }
 
 BOOST_AUTO_TEST_CASE(TestGetTimestampFromTimestamp)
@@ -950,18 +950,18 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromTimestamp)
 
     Timestamp ts = appBuf.GetTimestamp();
 
-    time_t cTime = utility::TimestampToCTime(ts);
+    tm tmDate;
 
-    tm *tmDate = std::gmtime(&cTime);
+    bool success = BinaryUtils::TimestampToCTm(ts, tmDate);
 
-    BOOST_REQUIRE(tmDate != 0);
+    BOOST_REQUIRE(success);
 
-    BOOST_CHECK_EQUAL(2004, tmDate->tm_year + 1900);
-    BOOST_CHECK_EQUAL(8, tmDate->tm_mon + 1);
-    BOOST_CHECK_EQUAL(14, tmDate->tm_mday);
-    BOOST_CHECK_EQUAL(6, tmDate->tm_hour);
-    BOOST_CHECK_EQUAL(34, tmDate->tm_min);
-    BOOST_CHECK_EQUAL(51, tmDate->tm_sec);
+    BOOST_CHECK_EQUAL(2004, tmDate.tm_year + 1900);
+    BOOST_CHECK_EQUAL(8, tmDate.tm_mon + 1);
+    BOOST_CHECK_EQUAL(14, tmDate.tm_mday);
+    BOOST_CHECK_EQUAL(6, tmDate.tm_hour);
+    BOOST_CHECK_EQUAL(34, tmDate.tm_min);
+    BOOST_CHECK_EQUAL(51, tmDate.tm_sec);
     BOOST_CHECK_EQUAL(573948623, ts.GetSecondFraction());
 }
 
@@ -986,18 +986,18 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromTimestamp)
 
     Date date = appBuf.GetDate();
 
-    time_t cTime = utility::DateToCTime(date);
+    tm tmDate;
 
-    tm *tmDate = std::gmtime(&cTime);
+    bool success = BinaryUtils::DateToCTm(date, tmDate);
 
-    BOOST_REQUIRE(tmDate != 0);
+    BOOST_REQUIRE(success);
 
-    BOOST_CHECK_EQUAL(2004, tmDate->tm_year + 1900);
-    BOOST_CHECK_EQUAL(8, tmDate->tm_mon + 1);
-    BOOST_CHECK_EQUAL(14, tmDate->tm_mday);
-    BOOST_CHECK_EQUAL(6, tmDate->tm_hour);
-    BOOST_CHECK_EQUAL(34, tmDate->tm_min);
-    BOOST_CHECK_EQUAL(51, tmDate->tm_sec);
+    BOOST_CHECK_EQUAL(2004, tmDate.tm_year + 1900);
+    BOOST_CHECK_EQUAL(8, tmDate.tm_mon + 1);
+    BOOST_CHECK_EQUAL(14, tmDate.tm_mday);
+    BOOST_CHECK_EQUAL(6, tmDate.tm_hour);
+    BOOST_CHECK_EQUAL(34, tmDate.tm_min);
+    BOOST_CHECK_EQUAL(51, tmDate.tm_sec);
 }
 
 BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
index 0ca5dad..55d1b92 100644
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -172,8 +172,11 @@ struct QueriesTestSuiteFixture
     {
         SQLRETURN ret;
 
-        testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
-        testCache.Put(2, TestType(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDate(1976, 1, 12), MakeTimestamp(1978, 8, 21, 23, 13, 45, 456)));
+        TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456));
+        TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDate(1976, 1, 12), MakeTimestamp(1978, 8, 21, 23, 13, 45, 456));
+
+        testCache.Put(1, in1);
+        testCache.Put(2, in2);
 
         const size_t columnsCnt = 11;
 
@@ -318,8 +321,11 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
 {
     SQLRETURN ret;
 
-    testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
-    testCache.Put(2, TestType(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDate(1976, 1, 12), MakeTimestamp(1978, 8, 21, 23, 13, 45, 999999999)));
+    TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456));
+    TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDate(1976, 1, 12), MakeTimestamp(1978, 8, 21, 23, 13, 45, 999999999));
+
+    testCache.Put(1, in1);
+    testCache.Put(2, in2);
 
     const size_t columnsCnt = 11;
 
@@ -408,7 +414,9 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
 {
     SQLRETURN ret;
 
-    testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
+    TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456));
+
+    testCache.Put(1, in);
 
     const size_t columnsCnt = 11;
 
@@ -467,7 +475,9 @@ BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
 {
     SQLRETURN ret;
 
-    testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
+    TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456));
+
+    testCache.Put(1, in);
 
     const size_t columnsCnt = 11;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/odbc/include/ignite/odbc.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc.h b/modules/platforms/cpp/odbc/include/ignite/odbc.h
index f613491..da662cf 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc.h
@@ -20,7 +20,6 @@
 
 #include "ignite/odbc/system/odbc_constants.h"
 
-
 /**
  * @file odbc.h
  *

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
index 43fdb96..f266a8f 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
@@ -174,21 +174,7 @@ namespace ignite
          * @return Standard string containing the same data.
          */
         std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen);
-
-        /**
-         * Convert Date type to standard C type time_t.
-         *
-         * @return Corresponding value of time_t.
-         */
-        time_t DateToCTime(const Date& date);
-
-        /**
-         * Convert Timestamp type to standard C type time_t.
-         *
-         * @return Corresponding value of time_t.
-         */
-        time_t TimestampToCTime(const Timestamp& ts);
     }
 }
 
-#endif
\ No newline at end of file
+#endif

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
index d108f39..600dc86 100644
--- a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
+++ b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,6 +19,8 @@
 #include <string>
 #include <sstream>
 
+#include "ignite/impl/binary/binary_utils.h"
+
 #include "ignite/odbc/system/odbc_constants.h"
 #include "ignite/odbc/app/application_data_buffer.h"
 #include "ignite/odbc/utility.h"
@@ -29,6 +31,8 @@ namespace ignite
     {
         namespace app
         {
+            using ignite::impl::binary::BinaryUtils;
+
             ApplicationDataBuffer::ApplicationDataBuffer() :
                 type(type_traits::IGNITE_ODBC_C_TYPE_UNSUPPORTED), buffer(0), buflen(0), reslen(0), offset(0)
             {
@@ -577,9 +581,9 @@ namespace ignite
             {
                 using namespace type_traits;
 
-                time_t time = utility::DateToCTime(value);
+                tm tmTime;
 
-                tm* tmTime = std::gmtime(&time);
+                BinaryUtils::DateToCTm(value, tmTime);
 
                 switch (type)
                 {
@@ -589,7 +593,7 @@ namespace ignite
 
                         if (buffer)
                         {
-                            strftime(buffer, GetSize(), "%Y-%m-%d", tmTime);
+                            strftime(buffer, GetSize(), "%Y-%m-%d", &tmTime);
 
                             if (GetResLen())
                                 *GetResLen() = strlen(buffer);
@@ -608,7 +612,7 @@ namespace ignite
                         {
                             std::string tmp(GetSize(), 0);
 
-                            strftime(&tmp[0], GetSize(), "%Y-%m-%d", tmTime);
+                            strftime(&tmp[0], GetSize(), "%Y-%m-%d", &tmTime);
 
                             SqlLen toCopy = std::min(static_cast<SqlLen>(strlen(tmp.c_str()) + 1), GetSize());
 
@@ -630,9 +634,9 @@ namespace ignite
                     {
                         SQL_DATE_STRUCT* buffer = reinterpret_cast<SQL_DATE_STRUCT*>(GetData());
 
-                        buffer->year = tmTime->tm_year + 1900;
-                        buffer->month = tmTime->tm_mon + 1;
-                        buffer->day = tmTime->tm_mday;
+                        buffer->year = tmTime.tm_year + 1900;
+                        buffer->month = tmTime.tm_mon + 1;
+                        buffer->day = tmTime.tm_mday;
 
                         break;
                     }
@@ -641,12 +645,12 @@ namespace ignite
                     {
                         SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<SQL_TIMESTAMP_STRUCT*>(GetData());
 
-                        buffer->year = tmTime->tm_year + 1900;
-                        buffer->month = tmTime->tm_mon + 1;
-                        buffer->day = tmTime->tm_mday;
-                        buffer->hour = tmTime->tm_hour;
-                        buffer->minute = tmTime->tm_min;
-                        buffer->second = tmTime->tm_sec;
+                        buffer->year = tmTime.tm_year + 1900;
+                        buffer->month = tmTime.tm_mon + 1;
+                        buffer->day = tmTime.tm_mday;
+                        buffer->hour = tmTime.tm_hour;
+                        buffer->minute = tmTime.tm_min;
+                        buffer->second = tmTime.tm_sec;
                         buffer->fraction = 0;
 
                         break;
@@ -688,9 +692,9 @@ namespace ignite
             {
                 using namespace type_traits;
 
-                time_t time = utility::TimestampToCTime(value);
+                tm tmTime;
 
-                tm* tmTime = std::gmtime(&time);
+                BinaryUtils::TimestampToCTm(value, tmTime);
 
                 switch (type)
                 {
@@ -700,7 +704,7 @@ namespace ignite
 
                         if (buffer)
                         {
-                            strftime(buffer, GetSize(), "%Y-%m-%d %H:%M:%S", tmTime);
+                            strftime(buffer, GetSize(), "%Y-%m-%d %H:%M:%S", &tmTime);
 
                             if (GetResLen())
                                 *GetResLen() = strlen(buffer);
@@ -719,7 +723,7 @@ namespace ignite
                         {
                             std::string tmp(GetSize(), 0);
 
-                            strftime(&tmp[0], GetSize(), "%Y-%m-%d %H:%M:%S", tmTime);
+                            strftime(&tmp[0], GetSize(), "%Y-%m-%d %H:%M:%S", &tmTime);
 
                             SqlLen toCopy = std::min(static_cast<SqlLen>(strlen(tmp.c_str()) + 1), GetSize());
 
@@ -741,9 +745,9 @@ namespace ignite
                     {
                         SQL_DATE_STRUCT* buffer = reinterpret_cast<SQL_DATE_STRUCT*>(GetData());
 
-                        buffer->year = tmTime->tm_year + 1900;
-                        buffer->month = tmTime->tm_mon + 1;
-                        buffer->day = tmTime->tm_mday;
+                        buffer->year = tmTime.tm_year + 1900;
+                        buffer->month = tmTime.tm_mon + 1;
+                        buffer->day = tmTime.tm_mday;
 
                         break;
                     }
@@ -752,12 +756,12 @@ namespace ignite
                     {
                         SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<SQL_TIMESTAMP_STRUCT*>(GetData());
 
-                        buffer->year = tmTime->tm_year + 1900;
-                        buffer->month = tmTime->tm_mon + 1;
-                        buffer->day = tmTime->tm_mday;
-                        buffer->hour = tmTime->tm_hour;
-                        buffer->minute = tmTime->tm_min;
-                        buffer->second = tmTime->tm_sec;
+                        buffer->year = tmTime.tm_year + 1900;
+                        buffer->month = tmTime.tm_mon + 1;
+                        buffer->day = tmTime.tm_mday;
+                        buffer->hour = tmTime.tm_hour;
+                        buffer->minute = tmTime.tm_min;
+                        buffer->second = tmTime.tm_sec;
                         buffer->fraction = value.GetSecondFraction();
 
                         break;
@@ -1136,9 +1140,7 @@ namespace ignite
                         break;
                 }
 
-                time_t cTime = mktime(&tmTime) - timezone;
-
-                return Date(cTime * 1000);
+                return BinaryUtils::CTmToDate(tmTime);
             }
 
             Timestamp ApplicationDataBuffer::GetTimestamp() const
@@ -1197,9 +1199,7 @@ namespace ignite
                         break;
                 }
 
-                time_t cTime = mktime(&tmTime) - timezone;
-
-                return Timestamp(cTime, nanos);
+                return BinaryUtils::CTmToTimestamp(tmTime, nanos);
             }
 
             template<typename T>

http://git-wip-us.apache.org/repos/asf/ignite/blob/06a3e917/modules/platforms/cpp/odbc/src/utility.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/utility.cpp b/modules/platforms/cpp/odbc/src/utility.cpp
index b33b742..8cdfdb6 100644
--- a/modules/platforms/cpp/odbc/src/utility.cpp
+++ b/modules/platforms/cpp/odbc/src/utility.cpp
@@ -125,16 +125,6 @@ namespace ignite
 
             return res;
         }
-
-        time_t DateToCTime(const Date& date)
-        {
-            return static_cast<time_t>(date.GetSeconds());
-        }
-
-        time_t TimestampToCTime(const Timestamp& ts)
-        {
-            return static_cast<time_t>(ts.GetSeconds());
-        }
     }
 }