00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef PTLIB_TIMEINTERVAL_H
00035 #define PTLIB_TIMEINTERVAL_H
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041
00043
00044
00055 class PTimeInterval : public PObject
00056 {
00057 PCLASSINFO(PTimeInterval, PObject);
00058
00059 public:
00073 PTimeInterval(
00074 PInt64 millisecs = 0
00075 );
00076 PTimeInterval(
00077 long millisecs,
00078 long seconds,
00079 long minutes = 0,
00080 long hours = 0,
00081 int days = 0
00082 );
00083 PTimeInterval(
00084 const PString & str
00085 );
00087
00096 PObject * Clone() const;
00097
00105 virtual Comparison Compare(
00106 const PObject & obj
00107 ) const;
00108
00112 virtual void PrintOn(
00113 ostream & strm
00114 ) const;
00115
00119 virtual void ReadFrom(
00120 istream & strm
00121 );
00123
00126 enum Formats {
00127 NormalFormat,
00128 IncludeDays,
00129 SecondsOnly
00130 };
00131
00132 PString AsString(
00133 int decimals = 3,
00134 Formats format = NormalFormat,
00135 int width = 1
00136 ) const;
00138
00146 virtual PInt64 GetMilliSeconds() const;
00147
00150 virtual void SetMilliSeconds(PInt64 msecs);
00151
00157 long GetSeconds() const;
00158
00164 long GetMinutes() const;
00165
00171 int GetHours() const;
00172
00178 int GetDays() const;
00179
00185 DWORD GetInterval() const;
00186
00198 virtual void SetInterval(
00199 PInt64 milliseconds = 0,
00200 long seconds = 0,
00201 long minutes = 0,
00202 long hours = 0,
00203 int days = 0
00204 );
00206
00214 PTimeInterval operator-() const;
00215
00221 PTimeInterval operator+(
00222 const PTimeInterval & interval
00223 ) const;
00224
00230 PTimeInterval & operator+=(
00231 const PTimeInterval & interval
00232 );
00233
00239 PTimeInterval operator-(
00240 const PTimeInterval & interval
00241 ) const;
00242
00248 PTimeInterval & operator-=(
00249 const PTimeInterval & interval
00250 );
00251
00257 PTimeInterval operator*(
00258 int factor
00259 ) const;
00260
00266 PTimeInterval & operator*=(
00267 int factor
00268 );
00269
00275 PTimeInterval operator/(
00276 int factor
00277 ) const;
00278
00284 PTimeInterval & operator/=(
00285 int factor
00286 );
00288
00298 bool operator==(
00299 const PTimeInterval & interval
00300 ) const;
00301 bool operator==(
00302 long msecs
00303 ) const;
00304
00312 bool operator!=(
00313 const PTimeInterval & interval
00314 ) const;
00315 bool operator!=(
00316 long msecs
00317 ) const;
00318
00326 bool operator> (
00327 const PTimeInterval & interval
00328 ) const;
00329 bool operator> (
00330 long msecs
00331 ) const;
00332
00340 bool operator>=(
00341 const PTimeInterval & interval
00342 ) const;
00343 bool operator>=(
00344 long msecs
00345 ) const;
00346
00354 bool operator< (
00355 const PTimeInterval & interval
00356 ) const;
00357 bool operator< (
00358 long msecs
00359 ) const;
00360
00368 bool operator<=(
00369 const PTimeInterval & interval
00370 ) const;
00371 bool operator<=(
00372 long msecs
00373 ) const;
00375
00376 private:
00377
00379 PInt64 m_milliseconds;
00380
00381
00382
00383 #ifdef _WIN32
00384 #include "msos/ptlib/timeint.h"
00385 #else
00386 #include "unix/ptlib/timeint.h"
00387 #endif
00388 };
00389
00390 #endif // PTLIB_TIMEINTERVAL_H
00391
00392
00393