Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:57:23

0001 #include "OnlineDB/Oracle/interface/Oracle.h"
0002 #include "OnlineDB/EcalCondDB/interface/Tm.h"
0003 #include "OnlineDB/EcalCondDB/interface/DateHandler.h"
0004 
0005 using namespace oracle::occi;
0006 
0007 DateHandler::DateHandler(Environment* env, Connection* conn) {
0008   m_env = env;
0009   m_conn = conn;
0010 
0011   PLUS_INF_DATE = maxDate();
0012   PLUS_INF = dateToTm(PLUS_INF_DATE);
0013   NEG_INF_DATE = minDate();
0014   NEG_INF = dateToTm(NEG_INF_DATE);
0015 }
0016 
0017 DateHandler::~DateHandler() {}
0018 
0019 Date DateHandler::tmToDate(const Tm& inTm) const {
0020   if (inTm.isNull()) {
0021     return Date();
0022   } else {
0023     struct tm ctm = inTm.c_tm();
0024     return Date(m_env, ctm.tm_year + 1900, ctm.tm_mon + 1, ctm.tm_mday, ctm.tm_hour, ctm.tm_min, ctm.tm_sec);
0025   }
0026 }
0027 
0028 Tm DateHandler::dateToTm(Date& date) const {
0029   if (date.isNull()) {
0030     return Tm();
0031   }
0032 
0033   int year;
0034   unsigned int mon;   // month
0035   unsigned int mday;  // day of month
0036   unsigned int hour;
0037   unsigned int min;  // minute
0038   unsigned int sec;  // second
0039 
0040   date.getDate(year, mon, mday, hour, min, sec);
0041 
0042   // work on the provided tm
0043   struct tm retTm;
0044   retTm.tm_year = year - 1900;
0045   retTm.tm_mon = mon - 1;
0046   retTm.tm_mday = mday;
0047   retTm.tm_hour = hour;
0048   retTm.tm_min = min;
0049   retTm.tm_sec = sec;
0050   retTm.tm_isdst = 0;
0051   retTm.tm_wday = 0;
0052   retTm.tm_yday = 0;
0053 
0054   mktime(&retTm);  // calculates tm_wday and tm_yday
0055 
0056   return Tm(&retTm);
0057 }