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 
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 }
Tm::isNull
int isNull() const
Definition: Tm.cc:46
min
T min(T a, T b)
Definition: MathUtil.h:58
DateHandler::tmToDate
oracle::occi::Date tmToDate(const Tm &inTm) const
Definition: DateHandler.cc:19
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
oracle::occi
Definition: ConnectionManager.h:7
LaserDQM_cfi.mon
mon
Definition: LaserDQM_cfi.py:3
Tm
Definition: Tm.h:13
web.browse_db.env
env
Definition: browse_db.py:18
DateHandler::DateHandler
DateHandler()=delete
Tm.h
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
Tm::c_tm
struct tm c_tm() const
Definition: Tm.cc:42
indexGen.date
date
Definition: indexGen.py:99
DateHandler::dateToTm
Tm dateToTm(oracle::occi::Date &date) const
Definition: DateHandler.cc:28
HBDarkeningEP_cfi.year
year
Definition: HBDarkeningEP_cfi.py:23
DateHandler::~DateHandler
~DateHandler()
Definition: DateHandler.cc:17
Oracle.h
DateHandler.h