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 _PTIMEINTERVAL
00035 #define _PTIMEINTERVAL
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 PInt64 GetMilliSeconds() const;
00147
00153 long GetSeconds() const;
00154
00160 long GetMinutes() const;
00161
00167 int GetHours() const;
00168
00174 int GetDays() const;
00175
00181 DWORD GetInterval() const;
00182
00194 virtual void SetInterval(
00195 PInt64 milliseconds = 0,
00196 long seconds = 0,
00197 long minutes = 0,
00198 long hours = 0,
00199 int days = 0
00200 );
00202
00210 PTimeInterval operator-() const;
00211
00217 PTimeInterval operator+(
00218 const PTimeInterval & interval
00219 ) const;
00220
00226 PTimeInterval & operator+=(
00227 const PTimeInterval & interval
00228 );
00229
00235 PTimeInterval operator-(
00236 const PTimeInterval & interval
00237 ) const;
00238
00244 PTimeInterval & operator-=(
00245 const PTimeInterval & interval
00246 );
00247
00253 PTimeInterval operator*(
00254 int factor
00255 ) const;
00256
00262 PTimeInterval & operator*=(
00263 int factor
00264 );
00265
00271 PTimeInterval operator/(
00272 int factor
00273 ) const;
00274
00280 PTimeInterval & operator/=(
00281 int factor
00282 );
00284
00294 bool operator==(
00295 const PTimeInterval & interval
00296 ) const;
00297 bool operator==(
00298 long msecs
00299 ) const;
00300
00308 bool operator!=(
00309 const PTimeInterval & interval
00310 ) const;
00311 bool operator!=(
00312 long msecs
00313 ) const;
00314
00322 bool operator> (
00323 const PTimeInterval & interval
00324 ) const;
00325 bool operator> (
00326 long msecs
00327 ) const;
00328
00336 bool operator>=(
00337 const PTimeInterval & interval
00338 ) const;
00339 bool operator>=(
00340 long msecs
00341 ) const;
00342
00350 bool operator< (
00351 const PTimeInterval & interval
00352 ) const;
00353 bool operator< (
00354 long msecs
00355 ) const;
00356
00364 bool operator<=(
00365 const PTimeInterval & interval
00366 ) const;
00367 bool operator<=(
00368 long msecs
00369 ) const;
00371
00372 protected:
00373
00375 PInt64 milliseconds;
00376
00377
00378
00379 #ifdef _WIN32
00380 #include "msos/ptlib/timeint.h"
00381 #else
00382 #include "unix/ptlib/timeint.h"
00383 #endif
00384 };
00385
00386 #endif
00387
00388
00389