class PTimeInterval

This class defines an arbitrary time interval to millisecond accuracy.

Inheritance:


Public Methods

[more] Construction
[more] Overrides from class PObject
[more] Access functions
[more] Operations
[more] Comparison functions

Protected Fields

[more]PInt64 milliseconds
Number of milliseconds in time interval


Inherited from PObject:

Public Methods

Run Time Type functions

I/O functions

Miscellaneous functions


Documentation

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.

o Construction

o 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:
              PTimeInterval(120000)
              PTimeInterval(60000, 60)
              PTimeInterval(60000, 0, 1)
              PTimeInterval(0, 60, 1)
              PTimeInterval(0, 0, 2)
Parameters:
millisecs - Number of milliseconds for interval.

o Overrides from class PObject

oPObject* Clone() const
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.

ovirtual Comparison Compare( const PObject & obj ) const
Rank the two time intervals. This ranks the intervals as you would expect for two integers.

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

ovirtual void PrintOn( ostream & strm ) const
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.

ovirtual void ReadFrom( istream & strm )
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.

o Conversion functions

o Access functions

oPInt64 GetMilliSeconds() const
Get the number of milliseconds for the time interval.

Returns:
very long integer number of milliseconds.

olong GetSeconds() const
Get the number of whole seconds for the time interval.

Returns:
long integer number of seconds.

olong GetMinutes() const
Get the number of whole minutes for the time interval.

Returns:
integer number of minutes.

oint GetHours() const
Get the number of whole hours for the time interval.

Returns:
integer number of hours.

oint GetDays() const
Get the number of whole days for the time interval.

Returns:
integer number of days.

oDWORD GetInterval() const
Get the number of milliseconds for the time interval.

Returns:
long integer number of milliseconds.

ovirtual void SetInterval( PInt64 milliseconds = 0, long seconds = 0, long minutes = 0, long hours = 0, int days = 0 )
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:
              SetInterval(120000)
              SetInterval(60000, 60)
              SetInterval(60000, 0, 1)
              SetInterval(0, 60, 1)
              SetInterval(0, 0, 2)
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.

o Operations

oPTimeInterval operator-() const
Unary minus, get negative of time interval.

Returns:
difference of the time intervals.

oPTimeInterval operator+( const PTimeInterval & interval ) const
Add the two time intervals yielding a third time interval.

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

oPTimeInterval& operator+=( const PTimeInterval & interval )
Add the second time interval to the first time interval.

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

oPTimeInterval operator-( const PTimeInterval & interval ) const
Subtract the two time intervals yielding a third time interval.

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

oPTimeInterval& operator-=( const PTimeInterval & interval )
Subtract the second time interval from the first time interval.

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

oPTimeInterval operator*( int factor ) const
Multiply the time interval by a factor yielding a third time interval.

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

oPTimeInterval& operator*=( int factor )
Multiply the time interval by a factor.

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

oPTimeInterval operator/( int factor ) const
Divide the time interval by a factor yielding a third time interval.

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

oPTimeInterval& operator/=( int factor )
Divide the time interval by a factor.

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

o Comparison functions

oBOOL 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.

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

oBOOL 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.

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

oBOOL 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.

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

oBOOL 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.

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

oBOOL 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.

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

oBOOL 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.

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

oPInt64 milliseconds
Number of milliseconds in time interval


Direct child classes:
PTimer

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.