00001 /****************************************************************************** 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 00011 00012 #ifndef absoluteTime_H_ 00013 #define absoluteTime_H_ 00014 00015 #include "lgrUtil.h" 00016 #include <iosfwd> 00017 #include <vlutil/vlString.h> 00018 00019 namespace MAKLogger 00020 { 00021 00022 class DT_DLL_LGRUTIL DtAbsoluteTime; 00023 00028 class DT_DLL_LGRUTIL DtRelativeTime 00029 { 00030 public: 00032 DtRelativeTime(double reltime); 00033 00035 DtRelativeTime(const DtAbsoluteTime& time1,const DtAbsoluteTime& time2); 00036 00038 DtRelativeTime operator+(const DtRelativeTime& relTime) const; 00039 00041 DtRelativeTime operator-(const DtRelativeTime& relTime) const; 00042 00044 bool operator==(const DtRelativeTime&) const; 00045 bool operator!=(const DtRelativeTime&) const; 00046 bool operator< (const DtRelativeTime&) const; 00047 bool operator> (const DtRelativeTime&) const; 00048 bool operator<=(const DtRelativeTime&) const; 00049 bool operator>=(const DtRelativeTime&) const; 00050 00051 double hours() const; 00052 double minutes() const; 00053 double seconds() const; 00054 00056 long hourPart() const; 00057 00059 long minutePart() const; 00060 00062 long secondPart() const; 00063 00065 long milisecondPart() const; 00066 00068 DtString toString(int percision = 0) const; 00069 00073 static double parseString(const DtString& timeString); 00074 00075 protected: 00076 double myTime; 00077 }; 00078 00082 class DT_DLL_LGRUTIL DtAbsoluteTime 00083 { 00084 public: 00087 DtAbsoluteTime(double absTime); 00088 00090 void offset(const DtRelativeTime& relTime); 00091 00093 DtRelativeTime relative(const DtAbsoluteTime& time2) const; 00094 00097 DtAbsoluteTime operator+(const DtRelativeTime& relTime) const; 00099 DtAbsoluteTime operator-(const DtRelativeTime& relTime) const; 00101 DtAbsoluteTime& operator+=(const DtRelativeTime& relTime); 00103 DtAbsoluteTime& operator-=(const DtRelativeTime& relTime); 00104 00105 DtRelativeTime operator-(const DtAbsoluteTime& absTime) const; 00106 00108 bool operator==(const DtAbsoluteTime&) const; 00109 bool operator!=(const DtAbsoluteTime&) const; 00110 bool operator< (const DtAbsoluteTime&) const; 00111 bool operator> (const DtAbsoluteTime&) const; 00112 bool operator<=(const DtAbsoluteTime&) const; 00113 bool operator>=(const DtAbsoluteTime&) const; 00114 00117 double hours() const; 00118 00121 double minutes() const; 00122 00125 double seconds() const; 00126 00128 long hourPart() const; 00129 00131 long minutePart() const; 00132 00134 long secondPart() const; 00135 00137 long milisecondPart() const; 00138 00140 DtString toString(int percision = 0) const; 00141 00146 static double parseString(const DtString& timeString); 00147 00148 protected: 00149 double myTime; 00150 }; 00151 00152 DT_DLL_LGRUTIL std::ostream& operator<<(std::ostream&,const DtAbsoluteTime&); 00153 00154 } 00155 00156 #endif