CMS 3D CMS Logo

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