aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/details
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-11-07 15:02:14 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-11-08 14:46:33 +0200
commit655fc5c0827d56b6eaa86f80c904d9a607530fcb (patch)
treecf4679282bb15dd15c73ff429e0b20428eb58650 /odb/oracle/details
parent60d4d13a85130ccdc3b232e420bc3c18683846b9 (diff)
Implement support for Oracle temporal types
Diffstat (limited to 'odb/oracle/details')
-rw-r--r--odb/oracle/details/date.hxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/odb/oracle/details/date.hxx b/odb/oracle/details/date.hxx
new file mode 100644
index 0000000..47137f6
--- /dev/null
+++ b/odb/oracle/details/date.hxx
@@ -0,0 +1,61 @@
+// file : odb/oracle/details/date.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_ORACLE_DETAILS_DATE_HXX
+#define ODB_ORACLE_DETAILS_DATE_HXX
+
+namespace odb
+{
+ // @@ Revise this.
+ //
+ namespace details
+ {
+ }
+
+ namespace oracle
+ {
+ namespace details
+ {
+ inline void
+ set_date (char* b,
+ short year,
+ unsigned char month,
+ unsigned char day,
+ unsigned char hour,
+ unsigned char minute,
+ unsigned char second)
+ {
+ b[0] = static_cast<char> (year / 100 + 100);
+ b[1] = static_cast<char> (year % 100 + 100);
+ b[2] = static_cast<char> (month);
+ b[3] = static_cast<char> (day);
+ b[4] = static_cast<char> (hour + 1);
+ b[5] = static_cast<char> (minute + 1);
+ b[6] = static_cast<char> (second + 1);
+ }
+
+ inline void
+ get_date (short& year,
+ unsigned char& month,
+ unsigned char& day,
+ unsigned char& hour,
+ unsigned char& minute,
+ unsigned char& second,
+ const char* b)
+ {
+ const unsigned char* ub (reinterpret_cast<const unsigned char*> (b));
+
+ year = 100 * ub[0] + ub[1] - 10100;
+ month = ub[2];
+ day = ub[3];
+ hour = ub[4] - 1;
+ minute = ub[5] - 1;
+ second = ub[6] - 1;
+ }
+ }
+ }
+}
+
+#endif // ODB_ORACLE_DETAILS_DATE_HXX