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 {
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 
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 }
struct tm c_tm() const
Definition: Tm.cc:56
oracle::occi::Date tmToDate(const Tm &inTm) const
Definition: DateHandler.cc:20
T min(T a, T b)
Definition: MathUtil.h:58
DateHandler()=delete
int isNull() const
Definition: Tm.cc:63
Tm dateToTm(oracle::occi::Date &date) const
Definition: DateHandler.cc:31
Definition: Tm.h:13