CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DateHandler Class Reference

#include <DateHandler.h>

Public Member Functions

 DateHandler (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
 DateHandler ()=delete
 
Tm dateToTm (oracle::occi::Date &date) const
 
oracle::occi::Date getCurrentDate ()
 
oracle::occi::Date getNegInfDate () const
 
Tm getNegInfTm () const
 
oracle::occi::Date getPlusInfDate () const
 
Tm getPlusInfTm () const
 
oracle::occi::Date maxDate ()
 
oracle::occi::Date minDate ()
 
oracle::occi::Date tmToDate (const Tm &inTm) const
 
 ~DateHandler ()
 

Private Attributes

oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 
Tm NEG_INF
 
oracle::occi::Date NEG_INF_DATE
 
Tm PLUS_INF
 
oracle::occi::Date PLUS_INF_DATE
 

Detailed Description

Definition at line 7 of file DateHandler.h.

Constructor & Destructor Documentation

◆ DateHandler() [1/2]

DateHandler::DateHandler ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

◆ ~DateHandler()

DateHandler::~DateHandler ( )

Definition at line 17 of file DateHandler.cc.

17 {}

◆ DateHandler() [2/2]

DateHandler::DateHandler ( )
delete

Member Function Documentation

◆ dateToTm()

Tm DateHandler::dateToTm ( oracle::occi::Date &  date) const

Translate an oracle Date object to a Tm object

Definition at line 28 of file DateHandler.cc.

References SiStripPI::min, LaserDQM_cfi::mon, fileinputsource_cfi::sec, and HLT_2023v12_cff::year.

28  {
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 }
Definition: Tm.h:13

◆ getCurrentDate()

oracle::occi::Date DateHandler::getCurrentDate ( )
inline

Get the current system date

Definition at line 20 of file DateHandler.h.

References m_env.

20 { return oracle::occi::Date(oracle::occi::Date::getSystemDate(m_env)); }
oracle::occi::Environment * m_env
Definition: DateHandler.h:46

◆ getNegInfDate()

oracle::occi::Date DateHandler::getNegInfDate ( ) const
inline

Definition at line 14 of file DateHandler.h.

References NEG_INF_DATE.

14 { return NEG_INF_DATE; }
oracle::occi::Date NEG_INF_DATE
Definition: DateHandler.h:51

◆ getNegInfTm()

Tm DateHandler::getNegInfTm ( ) const
inline

Definition at line 12 of file DateHandler.h.

References NEG_INF.

12 { return NEG_INF; }

◆ getPlusInfDate()

oracle::occi::Date DateHandler::getPlusInfDate ( ) const
inline

Definition at line 15 of file DateHandler.h.

References PLUS_INF_DATE.

15 { return PLUS_INF_DATE; }
oracle::occi::Date PLUS_INF_DATE
Definition: DateHandler.h:50

◆ getPlusInfTm()

Tm DateHandler::getPlusInfTm ( ) const
inline

Definition at line 13 of file DateHandler.h.

References PLUS_INF.

13 { return PLUS_INF; }

◆ maxDate()

oracle::occi::Date DateHandler::maxDate ( )
inline

The maximum oracle Date

Definition at line 30 of file DateHandler.h.

References m_env.

30 { return oracle::occi::Date(m_env, 9999, 12, 31, 23, 59, 59); }
oracle::occi::Environment * m_env
Definition: DateHandler.h:46

◆ minDate()

oracle::occi::Date DateHandler::minDate ( )
inline

The minimum oracle Date

Definition at line 25 of file DateHandler.h.

References m_env.

25 { return oracle::occi::Date(m_env, 1970, 1, 1, 0, 0, 0); }
oracle::occi::Environment * m_env
Definition: DateHandler.h:46

◆ tmToDate()

Date DateHandler::tmToDate ( const Tm inTm) const

Translate a Tm object to a oracle Date object

Definition at line 19 of file DateHandler.cc.

References Tm::c_tm(), and Tm::isNull().

19  {
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 }
struct tm c_tm() const
Definition: Tm.cc:42
oracle::occi::Environment * m_env
Definition: DateHandler.h:46
int isNull() const
Definition: Tm.cc:46

Member Data Documentation

◆ m_conn

oracle::occi::Connection* DateHandler::m_conn
private

Definition at line 45 of file DateHandler.h.

◆ m_env

oracle::occi::Environment* DateHandler::m_env
private

Definition at line 46 of file DateHandler.h.

Referenced by getCurrentDate(), maxDate(), and minDate().

◆ NEG_INF

Tm DateHandler::NEG_INF
private

Definition at line 49 of file DateHandler.h.

Referenced by getNegInfTm().

◆ NEG_INF_DATE

oracle::occi::Date DateHandler::NEG_INF_DATE
private

Definition at line 51 of file DateHandler.h.

Referenced by getNegInfDate().

◆ PLUS_INF

Tm DateHandler::PLUS_INF
private

Definition at line 48 of file DateHandler.h.

Referenced by getPlusInfTm().

◆ PLUS_INF_DATE

oracle::occi::Date DateHandler::PLUS_INF_DATE
private

Definition at line 50 of file DateHandler.h.

Referenced by getPlusInfDate().