CMS 3D CMS Logo

DateHandler.cc
Go to the documentation of this file.
4 
5 using namespace oracle::occi;
6 
7 DateHandler::DateHandler(Environment* env, Connection* conn) {
8  m_env = env;
9  m_conn = conn;
10 
11  PLUS_INF_DATE = maxDate();
12  PLUS_INF = dateToTm(PLUS_INF_DATE);
13  NEG_INF_DATE = minDate();
14  NEG_INF = dateToTm(NEG_INF_DATE);
15 }
16 
18 
19 Date DateHandler::tmToDate(const Tm& inTm) const {
20  if (inTm.isNull()) {
21  return Date();
22  } else {
23  struct tm ctm = inTm.c_tm();
24  return Date(m_env, ctm.tm_year + 1900, ctm.tm_mon + 1, ctm.tm_mday, ctm.tm_hour, ctm.tm_min, ctm.tm_sec);
25  }
26 }
27 
28 Tm DateHandler::dateToTm(Date& date) const {
29  if (date.isNull()) {
30  return Tm();
31  }
32 
33  int year;
34  unsigned int mon; // month
35  unsigned int mday; // day of month
36  unsigned int hour;
37  unsigned int min; // minute
38  unsigned int sec; // second
39 
40  date.getDate(year, mon, mday, hour, min, sec);
41 
42  // work on the provided tm
43  struct tm retTm;
44  retTm.tm_year = year - 1900;
45  retTm.tm_mon = mon - 1;
46  retTm.tm_mday = mday;
47  retTm.tm_hour = hour;
48  retTm.tm_min = min;
49  retTm.tm_sec = sec;
50  retTm.tm_isdst = 0;
51  retTm.tm_wday = 0;
52  retTm.tm_yday = 0;
53 
54  mktime(&retTm); // calculates tm_wday and tm_yday
55 
56  return Tm(&retTm);
57 }
oracle::occi::Date tmToDate(const Tm &inTm) const
Definition: DateHandler.cc:19
struct tm c_tm() const
Definition: Tm.cc:42
int isNull() const
Definition: Tm.cc:46
Tm dateToTm(oracle::occi::Date &date) const
Definition: DateHandler.cc:28
DateHandler()=delete
conn
Definition: getInfo.py:9
Definition: Tm.h:13