Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:15

0001 #include <iostream>
0002 #include <string>
0003 #include <time.h>
0004 
0005 #include "OnlineDB/EcalCondDB/interface/Tm.h"
0006 
0007 
0008 
0009 using namespace std;
0010 
0011 int main (int argc, char* argv[])
0012 {
0013   Tm t_0( (uint64_t) 0);
0014 
0015   cout << "t_0:                  " << t_0.str() << endl;
0016   cout << "t_0 micros:           " << t_0.microsTime() << endl;
0017 
0018   Tm t_0p( t_0.microsTime() );
0019 
0020   cout << "t_0p:                 " << t_0p.str() << endl;
0021   cout << "t_0p micros:          " << t_0p.microsTime() << endl << endl;
0022 
0023   Tm t_now;
0024   t_now.setToCurrentLocalTime();
0025 
0026   cout << "t_now:                " << t_now.str() << endl;
0027   cout << "t_now micros:         " << t_now.microsTime() << endl;
0028 
0029   Tm t_now_p( t_now.microsTime() );
0030 
0031   cout << "t_now_p:              " << t_now_p.str() << endl;
0032   cout << "t_now_p micros:       " << t_now_p.microsTime() << endl << endl;
0033 
0034   Tm t_now_gmt;
0035   t_now_gmt.setToCurrentGMTime();
0036 
0037   cout << "t_now_gmt:            " << t_now_gmt.str() << endl;
0038   cout << "t_now_gmt: micros:    " << t_now_gmt.microsTime() << endl;
0039 
0040   Tm t_now_gmt_p( t_now_gmt.microsTime() );
0041 
0042   cout << "t_now_gmt_p:          " << t_now_gmt_p.str() << endl;
0043   cout << "t_now_gmt_p: micros:  " << t_now_gmt_p.microsTime() << endl << endl;
0044 
0045   uint64_t inf = (uint64_t)-1;
0046   cout << "UINT64_MAX: " << inf << endl;
0047   Tm t_inf( inf ); 
0048 
0049   cout << "t_inf:          " << t_inf.str() << endl;
0050   cout << "t_inf: micros:  " << t_inf.microsTime() << endl;
0051 
0052   Tm t_inf_p( t_inf.microsTime() );
0053   cout << "t_inf_p:          " << t_inf_p.str() << endl;
0054   cout << "t_inf_p: micros:  " << t_inf_p.microsTime() << endl << endl;
0055 
0056   // daylight saving time
0057   Tm t_nodst(1249083000ULL * 1000000);
0058   cout << "t_nodst.dumpTm(): " << endl;
0059   t_nodst.dumpTm();
0060   cout << "t_nodst:             " << t_nodst.str() << endl;
0061   cout << "t_nodst micros:      " << t_nodst.microsTime() << endl;
0062 
0063   Tm t_nodst_p( t_nodst.microsTime() );
0064   cout << "t_nodst_p:           " << t_nodst_p.str() << endl;
0065   cout << "t_nodst_p micros:    " << t_nodst_p.microsTime() << endl << endl;
0066   
0067   struct tm tm_isdst = t_nodst.c_tm();
0068   mktime(&tm_isdst);
0069   Tm t_isdst(&tm_isdst);
0070   cout << "t_isdst.dumpTm(): " << endl;
0071   t_isdst.dumpTm();
0072   cout << "t_isdst:             " << t_isdst.str() << endl;
0073   cout << "t_isdst micros:      " << t_isdst.microsTime() << endl;
0074 
0075   Tm t_isdst_p( t_isdst.microsTime() );
0076   cout << "t_isdst_p:           " << t_isdst_p.str() << endl;
0077   cout << "t_isdst_p micros:    " << t_isdst_p.microsTime() << endl << endl;
0078 
0079   return 0;
0080 }