PTimeInterval Class Reference

#include <timeint.h>

Inheritance diagram for PTimeInterval:

PObject PTimer List of all members.

Conversion functions

enum  Formats { NormalFormat, IncludeDays, SecondsOnly }
PString AsString (int decimals=3, Formats format=NormalFormat, int width=1) const

Public Member Functions

Overrides from class PObject
PObjectClone () const
virtual Comparison Compare (const PObject &obj) const
virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
Access functions
PInt64 GetMilliSeconds () const
long GetSeconds () const
long GetMinutes () const
int GetHours () const
int GetDays () const
DWORD GetInterval () const
virtual void SetInterval (PInt64 milliseconds=0, long seconds=0, long minutes=0, long hours=0, int days=0)
Operations
PTimeInterval operator- () const
PTimeInterval operator+ (const PTimeInterval &interval) const
PTimeIntervaloperator+= (const PTimeInterval &interval)
PTimeInterval operator- (const PTimeInterval &interval) const
PTimeIntervaloperator-= (const PTimeInterval &interval)
PTimeInterval operator * (int factor) const
PTimeIntervaloperator *= (int factor)
PTimeInterval operator/ (int factor) const
PTimeIntervaloperator/= (int factor)
Comparison functions
bool operator== (const PTimeInterval &interval) const
bool operator== (long msecs) const
bool operator!= (const PTimeInterval &interval) const
bool operator!= (long msecs) const
bool operator> (const PTimeInterval &interval) const
bool operator> (long msecs) const
bool operator>= (const PTimeInterval &interval) const
bool operator>= (long msecs) const
bool operator< (const PTimeInterval &interval) const
bool operator< (long msecs) const
bool operator<= (const PTimeInterval &interval) const
bool operator<= (long msecs) const

Protected Attributes

PInt64 milliseconds
 Number of milliseconds in time interval.

Detailed Description

This class defines an arbitrary time interval to millisecond accuracy. The interval can be both positive and negative.

A long int is used to store the time interval so it is limited to LONG_MAX (found in the standard C header file limits.h) milliseconds. This is approximately 596 hours for 32 bit integers.

There is a constant, PMaxTimeInterval# which defines the maximum number of milliseconds that a time interval may be.


Member Enumeration Documentation

enum PTimeInterval::Formats

Enumerator:
NormalFormat 
IncludeDays 
SecondsOnly 


Constructor & Destructor Documentation

PINLINE PTimeInterval::PTimeInterval ( PInt64  millisecs = 0  ) 

Create a new time interval object. The time interval, in milliseconds, is the sum of all of the parameters. For example all of the following are equivalent: {verbatim} PTimeInterval(120000) PTimeInterval(60000, 60) PTimeInterval(60000, 0, 1) PTimeInterval(0, 60, 1) PTimeInterval(0, 0, 2) {verbatim}

Parameters:
millisecs  Number of milliseconds for interval.

PTimeInterval::PTimeInterval ( long  millisecs,
long  seconds,
long  minutes = 0,
long  hours = 0,
int  days = 0 
)

Parameters:
millisecs  Number of milliseconds for interval.
seconds  Number of seconds for interval.
minutes  Number of minutes for interval.
hours  Number of hours for interval.
days  Number of days for interval.

PTimeInterval::PTimeInterval ( const PString str  ) 

Parameters:
str  String representation of time interval.

PINLINE PTimeInterval::PTimeInterval ( PInt64  millisecs = 0  ) 

Create a new time interval object. The time interval, in milliseconds, is the sum of all of the parameters. For example all of the following are equivalent: {verbatim} PTimeInterval(120000) PTimeInterval(60000, 60) PTimeInterval(60000, 0, 1) PTimeInterval(0, 60, 1) PTimeInterval(0, 0, 2) {verbatim}

Parameters:
millisecs  Number of milliseconds for interval.

PTimeInterval::PTimeInterval ( long  millisecs,
long  seconds,
long  minutes = 0,
long  hours = 0,
int  days = 0 
)

Parameters:
millisecs  Number of milliseconds for interval.
seconds  Number of seconds for interval.
minutes  Number of minutes for interval.
hours  Number of hours for interval.
days  Number of days for interval.

PTimeInterval::PTimeInterval ( const PString str  ) 

Parameters:
str  String representation of time interval.


Member Function Documentation

PINLINE PObject * PTimeInterval::Clone (  )  const [virtual]

Create a new copy of the time interval. It is the responsibility of the called to delete the object.

Returns:
new time interval on heap.

Reimplemented from PObject.

virtual Comparison PTimeInterval::Compare ( const PObject obj  )  const [virtual]

Rank the two time intervals. This ranks the intervals as you would expect for two integers.

Returns:
EqualTo#, LessThan# or GreaterThan# depending on their relative rank.
Parameters:
obj  Time interval to compare against.

Reimplemented from PObject.

virtual void PTimeInterval::PrintOn ( ostream &  strm  )  const [virtual]

Output the time interval to the I/O stream. This outputs the number of milliseconds as a signed decimal integer number.

Parameters:
strm  I/O stream to output the time interval.

Reimplemented from PObject.

virtual void PTimeInterval::ReadFrom ( istream &  strm  )  [virtual]

Input the time interval from the I/O stream. This expects the input to be a signed decimal integer number.

Parameters:
strm  I/O stream to input the time interval from.

Reimplemented from PObject.

PString PTimeInterval::AsString ( int  decimals = 3,
Formats  format = NormalFormat,
int  width = 1 
) const

PINLINE PInt64 PTimeInterval::GetMilliSeconds (  )  const

Get the number of milliseconds for the time interval.

Returns:
very long integer number of milliseconds.

PINLINE long PTimeInterval::GetSeconds (  )  const

Get the number of whole seconds for the time interval.

Returns:
long integer number of seconds.

PINLINE long PTimeInterval::GetMinutes (  )  const

Get the number of whole minutes for the time interval.

Returns:
integer number of minutes.

PINLINE int PTimeInterval::GetHours (  )  const

Get the number of whole hours for the time interval.

Returns:
integer number of hours.

PINLINE int PTimeInterval::GetDays (  )  const

Get the number of whole days for the time interval.

Returns:
integer number of days.

DWORD PTimeInterval::GetInterval (  )  const

Get the number of milliseconds for the time interval.

Returns:
long integer number of milliseconds.

virtual void PTimeInterval::SetInterval ( PInt64  milliseconds = 0,
long  seconds = 0,
long  minutes = 0,
long  hours = 0,
int  days = 0 
) [virtual]

Set the value of the time interval. The time interval, in milliseconds, is the sum of all of the parameters. For example all of the following are equivalent: {verbatim} SetInterval(120000) SetInterval(60000, 60) SetInterval(60000, 0, 1) SetInterval(0, 60, 1) SetInterval(0, 0, 2) {verbatim}

Parameters:
milliseconds  Number of milliseconds for interval.
seconds  Number of seconds for interval.
minutes  Number of minutes for interval.
hours  Number of hours for interval.
days  Number of days for interval.

Reimplemented in PTimer.

PINLINE PTimeInterval PTimeInterval::operator- (  )  const

Unary minus, get negative of time interval.

Returns:
difference of the time intervals.

PINLINE PTimeInterval PTimeInterval::operator+ ( const PTimeInterval interval  )  const

Add the two time intervals yielding a third time interval.

Returns:
sum of the time intervals.
Parameters:
interval  Time interval to add.

PINLINE PTimeInterval & PTimeInterval::operator+= ( const PTimeInterval interval  ) 

Add the second time interval to the first time interval.

Returns:
reference to first time interval.
Parameters:
interval  Time interval to add.

PINLINE PTimeInterval PTimeInterval::operator- ( const PTimeInterval interval  )  const

Subtract the two time intervals yielding a third time interval.

Returns:
difference of the time intervals.
Parameters:
interval  Time interval to subtract.

PINLINE PTimeInterval & PTimeInterval::operator-= ( const PTimeInterval interval  ) 

Subtract the second time interval from the first time interval.

Returns:
reference to first time interval.
Parameters:
interval  Time interval to subtract.

PINLINE PTimeInterval PTimeInterval::operator * ( int  factor  )  const

Multiply the time interval by a factor yielding a third time interval.

Returns:
the time intervals times the factor.
Parameters:
factor  factor to multiply.

PINLINE PTimeInterval & PTimeInterval::operator *= ( int  factor  ) 

Multiply the time interval by a factor.

Returns:
reference to time interval.
Parameters:
factor  factor to multiply.

PINLINE PTimeInterval PTimeInterval::operator/ ( int  factor  )  const

Divide the time interval by a factor yielding a third time interval.

Returns:
the time intervals divided by the factor.
Parameters:
factor  factor to divide.

PINLINE PTimeInterval & PTimeInterval::operator/= ( int  factor  ) 

Divide the time interval by a factor.

Returns:
reference to time interval.
Parameters:
factor  factor to divide.

PINLINE bool PTimeInterval::operator== ( const PTimeInterval interval  )  const

Compare to the two time intervals. This is provided as an override to the default in PObject so that comparisons can be made to integer literals that represent milliseconds.

Returns:
PTrue if intervals are equal.
Parameters:
interval  Time interval to compare.

PINLINE bool PTimeInterval::operator== ( long  msecs  )  const

Parameters:
msecs  Time interval as integer milliseconds to compare.

PINLINE bool PTimeInterval::operator!= ( const PTimeInterval interval  )  const

Compare to the two time intervals. This is provided as an override to the default in PObject so that comparisons can be made to integer literals that represent milliseconds.

Returns:
PTrue if intervals are not equal.
Parameters:
interval  Time interval to compare.

PINLINE bool PTimeInterval::operator!= ( long  msecs  )  const

Parameters:
msecs  Time interval as integer milliseconds to compare.

PINLINE bool PTimeInterval::operator> ( const PTimeInterval interval  )  const

Compare to the two time intervals. This is provided as an override to the default in PObject so that comparisons can be made to integer literals that represent milliseconds.

Returns:
PTrue if intervals are greater than.
Parameters:
interval  Time interval to compare.

PINLINE bool PTimeInterval::operator> ( long  msecs  )  const

Parameters:
msecs  Time interval as integer milliseconds to compare.

PINLINE bool PTimeInterval::operator>= ( const PTimeInterval interval  )  const

Compare to the two time intervals. This is provided as an override to the default in PObject so that comparisons can be made to integer literals that represent milliseconds.

Returns:
PTrue if intervals are greater than or equal.
Parameters:
interval  Time interval to compare.

PINLINE bool PTimeInterval::operator>= ( long  msecs  )  const

Parameters:
msecs  Time interval as integer milliseconds to compare.

PINLINE bool PTimeInterval::operator< ( const PTimeInterval interval  )  const

Compare to the two time intervals. This is provided as an override to the default in PObject so that comparisons can be made to integer literals that represent milliseconds.

Returns:
PTrue if intervals are less than.
Parameters:
interval  Time interval to compare.

PINLINE bool PTimeInterval::operator< ( long  msecs  )  const

Parameters:
msecs  Time interval as integer milliseconds to compare.

PINLINE bool PTimeInterval::operator<= ( const PTimeInterval interval  )  const

Compare to the two time intervals. This is provided as an override to the default in PObject so that comparisons can be made to integer literals that represent milliseconds.

Returns:
PTrue if intervals are less than or equal.
Parameters:
interval  Time interval to compare.

PINLINE bool PTimeInterval::operator<= ( long  msecs  )  const

Parameters:
msecs  Time interval as integer milliseconds to compare.


Member Data Documentation

PInt64 PTimeInterval::milliseconds [protected]

Number of milliseconds in time interval.


The documentation for this class was generated from the following files:
Generated on Mon Feb 23 01:57:59 2009 for PTLib by  doxygen 1.5.1