blob: 55373bb74916b5b169bc1361bf717677cf3f643b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "command.h"
#include <string.h>
ODBC::TimeTypePair::TimeTypePair()
{
memset(&_c, 0, sizeof(_c));
memset(&_sql, 0, sizeof(_sql));
}
ODBC::TimeTypePair::TimeTypePair(const ODBC::TimeTypePair::SQL_TS& t)
{
memset(&_c, 0, sizeof(_c));
memset(&_sql, 0, sizeof(_sql));
set(t);
}
ODBC::TimeTypePair::TimeTypePair(tm const& t)
{
memset(&_c, 0, sizeof(_c));
memset(&_sql, 0, sizeof(_sql));
set(t);
}
tm const&
ODBC::TimeTypePair::set(const ODBC::TimeTypePair::SQL_TS& t)
{
_sql = t;
sql2c();
return _c;
}
void
ODBC::TimeTypePair::sql2c() const
{
_c.tm_year = _sql.year - 1900;
_c.tm_mon = _sql.month - 1;
_c.tm_mday = _sql.day;
_c.tm_hour = _sql.hour;
_c.tm_min = _sql.minute;
_c.tm_sec = _sql.second;
}
const ODBC::TimeTypePair::SQL_TS&
ODBC::TimeTypePair::set(tm const& t)
{
_c = t;
c2sql();
return _sql;
}
void
ODBC::TimeTypePair::c2sql() const
{
_sql.year = _c.tm_year + 1900;
_sql.month = _c.tm_mon + 1;
_sql.day = _c.tm_mday;
_sql.hour = _c.tm_hour;
_sql.minute = _c.tm_min;
_sql.second = _c.tm_sec;
_sql.fraction = 0;
}
|