CMS 3D CMS Logo

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

#include <DateHandler.h>

Public Member Functions

 DateHandler (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
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 Member Functions

 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 8 of file DateHandler.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file DateHandler.cc.

18 {}
DateHandler::DateHandler ( )
private

Referenced by maxDate().

Member Function Documentation

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

Translate an oracle Date object to a Tm object

Definition at line 31 of file DateHandler.cc.

References min(), LaserDQM_cfi::mon, and create_public_lumi_plots::year.

Referenced by RunCommentDat::fetchData(), FEConfigSpikeInfo::fetchData(), FEConfigTimingInfo::fetchData(), ODCond2ConfInfo::fetchData(), FEConfigPedInfo::fetchData(), FEConfigLinInfo::fetchData(), FEConfigSlidingInfo::fetchData(), FEConfigLUTInfo::fetchData(), FEConfigFgrInfo::fetchData(), FEConfigWeightInfo::fetchData(), ODRunConfigInfo::fetchData(), FEConfigMainInfo::fetchData(), RunList::fetchGlobalRunsByLocation(), FEConfigSpikeInfo::fetchLastData(), FEConfigTimingInfo::fetchLastData(), FEConfigWeightInfo::fetchLastData(), FEConfigPedInfo::fetchLastData(), FEConfigFgrInfo::fetchLastData(), FEConfigSlidingInfo::fetchLastData(), FEConfigLinInfo::fetchLastData(), FEConfigLUTInfo::fetchLastData(), MonRunList::fetchLastNRuns(), RunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), RunList::fetchRunsByLocation(), DCSPTMTempList::fetchValuesForECID(), DCSPTMTempList::fetchValuesForECIDAndTime(), RunDCSMagnetDat::fillTheMap(), RunDCSLVDat::fillTheMap(), RunDCSHVDat::fillTheMap(), LMFCorrCoefDat::getCorrections(), LMFIOV::getParameters(), LMFRunIOV::getParameters(), LMFSeqDat::getParameters(), maxDate(), DCUIOV::setByID(), CaliIOV::setByID(), MODRunIOV::setByID(), MonRunIOV::setByID(), FEConfigSpikeInfo::setByID(), FEConfigTimingInfo::setByID(), RunIOV::setByID(), FEConfigLUTInfo::setByID(), FEConfigWeightInfo::setByID(), FEConfigFgrInfo::setByID(), FEConfigPedInfo::setByID(), FEConfigLinInfo::setByID(), FEConfigSlidingInfo::setByID(), ODRunConfigInfo::setByID(), FEConfigMainInfo::setByID(), RunIOV::setByRecentData(), MODRunIOV::setByRun(), MonRunIOV::setByRun(), RunIOV::setByRun(), DCUIOV::setByTm(), and CaliIOV::setByTm().

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 }
T min(T a, T b)
Definition: MathUtil.h:58
Definition: Tm.h:13
oracle::occi::Date DateHandler::getCurrentDate ( )
inline

Get the current system date

Definition at line 22 of file DateHandler.h.

References m_env.

23  {
24  return oracle::occi::Date(oracle::occi::Date::getSystemDate(m_env));
25  }
oracle::occi::Environment * m_env
Definition: DateHandler.h:56
oracle::occi::Date DateHandler::getNegInfDate ( ) const
inline

Definition at line 16 of file DateHandler.h.

References NEG_INF_DATE.

16 { return NEG_INF_DATE; }
oracle::occi::Date NEG_INF_DATE
Definition: DateHandler.h:61
Tm DateHandler::getNegInfTm ( ) const
inline

Definition at line 14 of file DateHandler.h.

References NEG_INF.

14 { return NEG_INF; }
oracle::occi::Date DateHandler::getPlusInfDate ( ) const
inline

Definition at line 17 of file DateHandler.h.

References PLUS_INF_DATE.

17 { return PLUS_INF_DATE; }
oracle::occi::Date PLUS_INF_DATE
Definition: DateHandler.h:60
Tm DateHandler::getPlusInfTm ( ) const
inline
oracle::occi::Date DateHandler::maxDate ( )
inline

The maximum oracle Date

Definition at line 38 of file DateHandler.h.

References indexGen::date, DateHandler(), dateToTm(), m_env, and tmToDate().

39  {
40  return oracle::occi::Date(m_env, 9999, 12, 31, 23, 59, 59);
41  }
oracle::occi::Environment * m_env
Definition: DateHandler.h:56
oracle::occi::Date DateHandler::minDate ( )
inline

The minimum oracle Date

Definition at line 30 of file DateHandler.h.

References m_env.

31  {
32  return oracle::occi::Date(m_env, 1970, 1, 1, 0, 0, 0);
33  }
oracle::occi::Environment * m_env
Definition: DateHandler.h:56
Date DateHandler::tmToDate ( const Tm inTm) const

Translate a Tm object to a oracle Date object

Definition at line 20 of file DateHandler.cc.

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

Referenced by DCUIOV::fetchID(), CaliIOV::fetchID(), MODRunIOV::fetchID(), MonRunIOV::fetchID(), RunIOV::fetchID(), LMFIOV::fetchIdSql(), LMFLmrSubIOV::fetchIdSql(), DCSPTMTempList::fetchValuesForECIDAndTime(), RunDCSHVDat::getBarrelRset(), RunDCSHVDat::getEndcapAnodeRset(), RunDCSHVDat::getEndcapDynodeRset(), LMFLmrSubIOV::getIOVIDsLaterThan(), maxDate(), DCUIOV::setByTm(), CaliIOV::setByTm(), RunIOV::updateEndTimeDB(), RunIOV::updateStartTimeDB(), DCUIOV::writeDB(), CaliIOV::writeDB(), ODCond2ConfInfo::writeDB(), MODRunIOV::writeDB(), MonRunIOV::writeDB(), RunIOV::writeDB(), LMFIOV::writeDBSql(), LMFRunIOV::writeDBSql(), LMFSeqDat::writeDBSql(), and LMFLmrSubIOV::writeDBSql().

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

Member Data Documentation

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

Definition at line 55 of file DateHandler.h.

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

Definition at line 56 of file DateHandler.h.

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

Tm DateHandler::NEG_INF
private

Definition at line 59 of file DateHandler.h.

Referenced by getNegInfTm().

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

Definition at line 61 of file DateHandler.h.

Referenced by getNegInfDate().

Tm DateHandler::PLUS_INF
private

Definition at line 58 of file DateHandler.h.

Referenced by getPlusInfTm().

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

Definition at line 60 of file DateHandler.h.

Referenced by getPlusInfDate().