00001
00002
00003
00004 #include "PSTime/Time.h"
00005
00006 #include <iostream>
00007 #include <time.h>
00008
00009
00010 using namespace std;
00011 using namespace PSTime;
00012
00013 int main ()
00014 {
00015 cout << "\n\nTest implementation of the class PSTime\n";
00016
00017
00018 cout << "\n\n\nTest Time *UTCtime1 = new Time();\n";
00019 Time *UTCtime1 = new Time();
00020 cout << *UTCtime1 << endl;
00021
00022
00023
00024
00025
00026
00027
00028
00029 cout << "\n\n\nTest Time *UTCtime2 = new Time(*UTCtime1);\n";
00030 Time *UTCtime2 = new Time(*UTCtime1);
00031 cout << *UTCtime2 << endl;
00032
00033
00034
00035 cout << "\n\n\nTest Time *UTCtime3 = new Time(UTCtime1->getUTCSec()+10,UTCtime1->getUTCNsec()+10);\n";
00036 Time *UTCtime3 = new Time(UTCtime1->sec()+10,UTCtime1->nsec()+10);
00037 cout << *UTCtime3 << endl;
00038
00039
00040
00041 cout << "\n\n\nTest Time *UTCtime4 = new Time(year,month,day,hour,min,sec,nsec,zone)";
00042 cout << "\n for parameters (2010,10,8,17,04,43,123456,Time::UTC);\n";
00043 Time *UTCtime4 = new Time(2010,10,8,17,04,43,123456,Time::UTC);
00044 cout << *UTCtime4 << endl;
00045
00046 cout << "\n for parameters (2010,10,8,17,04,43,123456,Time::Local);\n";
00047 Time *UTCtime5 = new Time(2010,10,8,17,04,43,123456,Time::Local);
00048 cout << *UTCtime5 << endl;
00049
00050 cout << "\n for parameters (2010,10,8,17,04,43,123456,Time::Local);\n";
00051 Time *UTCtime6 = new Time(2010,10,8,17,04,43,123456,Time::Local);
00052 cout << *UTCtime6 << endl;
00053
00054
00055 struct timespec currentHRTime;
00056 int gettimeStatus = 0;
00057 gettimeStatus = clock_gettime( CLOCK_REALTIME, ¤tHRTime );
00058 cout << "\n\n\nTest Time *UTCtime7 = new Time(currentHRTime);\n";
00059 Time *UTCtime7 = new Time(currentHRTime);
00060 cout << *UTCtime7 << endl;
00061
00062
00063 time_t local=time(NULL);
00064 tm locTime=*localtime(&local);
00065 tm utcTime=*gmtime(&local);
00066
00067 cout << "\n\n\nTest Time *UTCtime8 = new Time(utcTime,Time::UTC);\n";
00068 Time *UTCtime8 = new Time(utcTime,Time::UTC);
00069 cout << *UTCtime8 << endl;
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 time_t sec = 1287712731;
00104 time_t nsec = 123456789;
00105
00106 Time *UTCtime9 = new Time(sec,nsec);
00107
00108 cout << *UTCtime9 << endl;
00109
00110
00111
00112
00113
00114
00115
00116
00117 cout << "\n\nTest UTCtime9->asStringCompact(Time::Local) : " << UTCtime9->asStringCompact(Time::Local) << endl ;
00118 cout << "\n\nTest UTCtime9->asStringCompact(Time::Local,5) : " << UTCtime9->asStringCompact(Time::Local,5) << endl ;
00119 cout << "\n\nTest UTCtime9->asStringCompact(Time::Local,0) : " << UTCtime9->asStringCompact(Time::Local,0) << endl ;
00120
00121 cout << "\n\nTest UTCtime9->asString(Time::Local) : " << UTCtime9->asString(Time::Local) << endl ;
00122 cout << "\n\nTest UTCtime9->asString(Time::Local,3) : " << UTCtime9->asString(Time::Local,3) << endl ;
00123 cout << "\n\nTest UTCtime9->asString(Time::Local,0) : " << UTCtime9->asString(Time::Local,0) << endl ;
00124
00125 cout << "\n\nTest UTCtime9->asStringFormat() : " << UTCtime9->asStringFormat() << endl ;
00126 cout << "\n\nTest UTCtime9->asStringFormat(<DateTime format>,Time::Local) : " <<
00127 UTCtime9->asStringFormat("%Y%m%d %H:%M:%S%.4f%z",Time::Local) << endl ;
00128
00129
00130
00131 return 0;
00132
00133 }