#include "CoralBase/TimeStamp.h"
#include "RPCSourceHandler.h"
Go to the source code of this file.
Functions | |
int | TtoUT (coral::TimeStamp time) |
coral::TimeStamp | UTtoT (int utime) |
int TtoUT | ( | coral::TimeStamp | time | ) |
Definition at line 14 of file TimeConv.cc.
References min, and LaserDQM_cfi::mon.
Referenced by popcon::RpcData::getNewObjects().
00015 { 00016 // seconds since 1/1/1970 00017 int yea = time.year(); 00018 int mon = time.month(); 00019 int day = time.day(); 00020 int hou = time.hour(); 00021 int min = time.minute(); 00022 int sec = time.second(); 00023 int yes = (yea-1970)*31536000; 00024 int cony = (yea-1972)%4; 00025 if (cony == 0) yes = yes + (yea-1972)/4*86400; 00026 else yes = yes + ((yea-1972)/4 - 1)*86400; 00027 int conm = (mon - 1); 00028 int mos = 0; 00029 switch (conm) { 00030 case 1 : 00031 mos = 31*86400; 00032 break; 00033 case 2 : 00034 mos = 59*86400; 00035 break; 00036 case 3 : 00037 mos = 90*86400; 00038 break; 00039 case 4 : 00040 mos = 120*86400; 00041 break; 00042 case 5 : 00043 mos = 151*86400; 00044 break; 00045 case 6 : 00046 mos = 181*86400; 00047 break; 00048 case 7 : 00049 mos = 212*86400; 00050 break; 00051 case 8 : 00052 mos = 243*86400; 00053 break; 00054 case 9 : 00055 mos = 273*86400; 00056 break; 00057 case 10 : 00058 mos = 304*86400; 00059 break; 00060 case 11 : 00061 mos = 334*86400; 00062 break; 00063 } 00064 int das = (day - 1)*86400; 00065 int hos = hou*3600; 00066 int mis = min*60; 00067 int utime = yes + mos + das + hos + mis + sec; 00068 return utime; 00069 }
coral::TimeStamp UTtoT | ( | int | utime | ) |
Definition at line 74 of file TimeConv.cc.
References min, and LaserDQM_cfi::mon.
Referenced by RPCFw::createIMON(), RPCFw::createSTATUS(), and RPCFw::createVMON().
00075 { 00076 int yea = static_cast<int>(trunc(utime/31536000) + 1970); 00077 int yes = (yea-1970)*31536000; 00078 int cony = (yea-1972)%4; 00079 if (cony == 0) yes = yes + (yea-1972)/4*86400; 00080 else yes = yes + static_cast<int>(trunc((yea-1972)/4))*86400; 00081 int day = static_cast<int>(trunc((utime - yes)/86400)); 00082 int rest = static_cast<int>(utime - yes - day*86400); 00083 int mon = 0; 00084 // BISESTILE YEAR 00085 if (cony == 0) { 00086 day = day + 1; 00087 if (day < 32){ 00088 mon = 1; 00089 day = day - 0; 00090 } 00091 if (day >= 32 && day < 61){ 00092 mon = 2; 00093 day = day - 31; 00094 } 00095 if (day >= 61 && day < 92){ 00096 mon = 3; 00097 day = day - 60; 00098 } 00099 if (day >= 92 && day < 122){ 00100 mon = 4; 00101 day = day - 91; 00102 } 00103 if (day >= 122 && day < 153){ 00104 mon = 5; 00105 day = day - 121; 00106 } 00107 if (day >= 153 && day < 183){ 00108 mon = 6; 00109 day = day - 152; 00110 } 00111 if (day >= 183 && day < 214){ 00112 mon = 7; 00113 day = day - 182; 00114 } 00115 if (day >= 214 && day < 245){ 00116 mon = 8; 00117 day = day - 213; 00118 } 00119 if (day >= 245 && day < 275){ 00120 mon = 9; 00121 day = day - 244; 00122 } 00123 if (day >= 275 && day < 306){ 00124 mon = 10; 00125 day = day - 274; 00126 } 00127 if (day >= 306 && day < 336){ 00128 mon = 11; 00129 day = day - 305; 00130 } 00131 if (day >= 336){ 00132 mon = 12; 00133 day = day - 335; 00134 } 00135 } 00136 // NOT BISESTILE YEAR 00137 else { 00138 if (day < 32){ 00139 mon = 1; 00140 day = day - 0; 00141 } 00142 if (day >= 32 && day < 60){ 00143 mon = 2; 00144 day = day - 31; 00145 } 00146 if (day >= 60 && day < 91){ 00147 mon = 3; 00148 day = day - 59; 00149 } 00150 if (day >= 91 && day < 121){ 00151 mon = 4; 00152 day = day - 90; 00153 } 00154 if (day >= 121 && day < 152){ 00155 mon = 5; 00156 day = day - 120; 00157 } 00158 if (day >= 152 && day < 182){ 00159 mon = 6; 00160 day = day - 151; 00161 } 00162 if (day >= 182 && day < 213){ 00163 mon = 7; 00164 day = day - 181; 00165 } 00166 if (day >= 213 && day < 244){ 00167 mon = 8; 00168 day = day - 212; 00169 } 00170 if (day >= 244 && day < 274){ 00171 mon = 9; 00172 day = day - 243; 00173 } 00174 if (day >= 274 && day < 305){ 00175 mon = 10; 00176 day = day - 273; 00177 } 00178 if (day >= 305 && day < 335){ 00179 mon = 11; 00180 day = day - 304; 00181 } 00182 if (day >= 335){ 00183 mon = 12; 00184 day = day - 334; 00185 } 00186 } 00187 00188 int hou = static_cast<int>(trunc(rest/3600)); 00189 rest = rest - hou*3600; 00190 int min = static_cast<int>(trunc(rest/60)); 00191 rest = rest - min*60; 00192 int sec = rest; 00193 int nan = 0; 00194 00195 // std::cout <<">> Processing since: "<<day<<"/"<<mon<<"/"<<yea<<" "<<hou<<":"<<min<<"."<<sec<< std::endl; 00196 00197 coral::TimeStamp Tthr; 00198 00199 Tthr = coral::TimeStamp(yea, mon, day, hou, min, sec, nan); 00200 return Tthr; 00201 }