Main Table of Contents


Table of Contents

class PtTime
PtTime: class summary
PtTime::PtTime()
PtTime::~PtTime()
PtTime::Hour()
PtTime::IsTime()
PtTime::Minutes()
PtTime::Now()
PtTime::Seconds()
PtTime::operator + ()
PtTime::operator - ()
PtTime::operator ++ ()
PtTime::operator -- ()
PtTime::operator += ()
PtTime::operator -= ()
PtTime::operator = ()
PtTime::operator < ()
PtTime::operator > ()
PtTime::operator == ()
PtTime::operator != ()
PtTime::operator long()

class PtTime


Intro
PtTime: class summary
PtTime::PtTime()
PtTime::~PtTime()
PtTime::Hour()
PtTime::IsTime()
PtTime::Minutes()
PtTime::Now()
PtTime::Seconds()
PtTime::operator + ()
PtTime::operator - ()
PtTime::operator ++ ()
PtTime::operator -- ()
PtTime::operator += ()
PtTime::operator -= ()
PtTime::operator = ()
PtTime::operator < ()
PtTime::operator > ()
PtTime::operator == ()
PtTime::operator != ()
PtTime::operator long()

PtTime is a class which is used to represent times. This class is registered in the type manager.

It is not generally safe to derive your class from a class which is registered in the type manager. You may create a time class which contains a PtTime, but you may not derive a class from PtTime.


PtTime: class summary


Intro

Files to include Class declaration Base class
poet.hxx ptcomp.hxx none

Member functions:

constructor PtTime();
destructor ~PtTime();
Hour char Hour() const;
Hour char& Hour();
IsTime int IsTime();
Minutes char Minutes() const;
Minutes char& Minutes();
Now PtTime& Now();
operator + PtTime operator + (long seconds);
operator - PtTime operator - (PtTime& time);
operator ++ PtTime& operator ++ ();
operator -- PtTime& operator -- ();
operator -- PtTime& operator -- ();
operator += PtTime& operator += (long seconds);
operator -= PtTime& operator -= (long seconds);
operator = PtTime& operator = (const PtTime& );
operator < int operator < (PtTime& );
operator > int operator > (PtTime& );
operator == int operator == (PtTime& );
operator != int operator != (PtTime& );
operator long operator long();
Seconds char Seconds() const;
Seconds char& Seconds();

PtTime::PtTime()


Intro

Declarations:

PtTime::PtTime()
PtTime::PtTime(long seconds)

PtTime::PtTime(const PtTime& time)

Each of these is described separately below.

Declaration:

PtTime::PtTime()

Description:

Constructor. Initializes the time to the current system time.

Declaration:

PtTime::PtTime(long seconds)

Description:

Constructor. Initializes the time to the given number of seconds.

Declaration:

PtTime::PtTime(char h, char m, char s)

Description:

Constructor. Initializes the time to the given hour, minutes, and seconds.

Declaration:

PtTime::PtTime(const PtTime& time)

Description:

Copy constructor. Initializes the new time to the value contained in another time.

Example:

PtTime QuittingTime((char) 19, (char) 0, (char) 0);
PtTime DesiredTime = QuittingTime;

PtTime::~PtTime()


Intro

Declaration:

PtTime::~PtTime()

Description:

Destructor for PtTime.


PtTime::Hour()


Intro

Declaration:

char& PtTime::Hour()

Description:

A method used to get or set the hour.

Returns:

The hour member (by reference).

Example:

PtTime time;
time.Hour() = 3; // setting the hour
cout << (int) time.Hour(); // reading the hour

Note:

The cast in the last line is necessary if the hour is to be printed as an integer.

Declaration:

char PtTime::Hour() const

Description:

A method used to get the hour.

Returns:

The hour.


PtTime::IsTime()


Intro

Declaration:

int PtTime::IsTime()

Description:

Checks whether the time is valid.

Returns:

0 Not a valid time
Non-zero Valid time

PtTime::Minutes()


Intro

Declaration:

char& PtTime::Minutes(short)

Description:

A method used to get or set minutes.

Returns:

The minutes member (by reference).

Example:

PtTime time;
time.Minutes() = 3; // setting the minutes
cout << (int) time.Minutes(); // reading the minutes

Note:

The cast in the last line is necessary if minutes is to be printed as an integer.

Declaration:

char PtTime::Minutes(short) const

Description:

A method used to get minutes.

Returns:

The minutes.


PtTime::Now()


Intro

Declaration:

PtTime& PtTime::Now()

Description:

Returns the current time.


PtTime::Seconds()


Intro

Declaration:

char& PtTime::Seconds(short)

Description:

A method used to get or set seconds.

Returns:

The seconds member (by reference).

Example:

PtTime time;
time.Seconds() = 3; // Setting seconds
cout << (int) time.Seconds();// Reading seconds

Note:

The cast in the last line is necessary if seconds is to be printed as an integer.

Declaration:

char PtTime::Seconds(short) const

Description:

A method used to get seconds.

Returns:

The seconds.


PtTime::operator + ()


Intro

Declaration:

PtTime PtTime::operator + (int n)

Description:

Adds n seconds to the time.

Returns:

The result of the addition.


PtTime::operator - ()


Intro

Declaration:

PtTime PtTime::operator - (PtTime& time) PtTime PtTime::operator - (long seconds)

Description:

Subtracts one time from another, returning the difference between the two times.

Returns:

The result of the subtraction.

Example:

PtTime timeA ( (char) 3, (char) 10, (char) 25);
PtTime timeB ( (char) 2, (char) 5, (char) 10);
PtTime result;
result = timeA - timeB;

PtTime::operator ++ ()


Intro

Declaration:

PtTime& PtTime::operator ++ ()

Description:

Increments the time. Only the prefix operator has been implemented.

Returns:

The incremented time.

Example:

PtTIme aTime;
++aTime;
// *not* aTime++;

PtTime::operator -- ()


Intro

Declaration:

PtTime& PtTime::operator -- ()

Description:

Decrements the time. Only the prefix operator has been implemented.

Returns:

The decremented time.

Example:

PtTIme aTime;
--aTime;
// *not* aTime--;

PtTime::operator += ()


Intro

Declaration:

PtTime& PtTime::operator += (long seconds)

Description:

Adds seconds to the time.

Returns:

The resulting time.

Example:

PtTime aTime, bTime;
aTime += bTime;

PtTime::operator -= ()


Intro

Declaration:

PtTime& PtTime::operator -= (long seconds)

Description:

Subtracts seconds from the time.

Returns:

The resulting time.

Example:

PtTime aTime;
aTime -= 10;

PtTime::operator = ()


Intro

Declaration:

PtTime& PtTime::operator = (const PtTime& )

Description:

Assigns one time to another.

Returns:

The resulting time.

Example:

PtTime aTime, bTime;
aTime = bTime;

PtTime::operator < ()


Intro

Declaration:

int PtTime::operator < (PtTime& )

Description:

"Less than" operator.

Returns:

0 Not less than
Non-zero Less than

Example:

PtTime aTime, bTime;
aTime -= 1;
if (aTime < bTime)
cout << "Yup, it really is less than!" << endl;

PtTime::operator > ()


Intro

Declaration:

int PtTime::operator > (PtTime& )

Description:

"Greater than" operator.

Returns:

0 Not greater than
Non-zero Greater than

Example:

PtTime aTime, bTime;
aTime += 1;
if (aTime > bTime)
cout << "Yup, it really is greater than!" << endl;

PtTime::operator == ()


Intro

Declaration:

int PtTime::operator == (PtTime& )

Description:

"Is equal to" operator.

Returns:

0 Not equal
Non-zero Equal

Example:

PtTime aTime, bTime;
if (aTime == bTime)
cout << "Isn't equality great?" << endl;

PtTime::operator != ()


Intro

Declaration:

int PtTime::operator != (PtTime& )

Description:

"Is not equal to" operator.

Returns:

0 Not equal
-1 This time is less than the parameter
+1 This time is greater than the parameter

Example:

PtTime TimeLimit;'
PtTime Duration;
TimeTrial(&TimeLimit, &Duration);
switch ( Duration != TimeLimit )
{
case -1 :
case 0 :
cout << "Within PtTime limit";
break;
case 1 :
cout << "Out of PtTime limit";
break;
}

PtTime::operator long()


Intro

Declaration:

PtTime::operator long()

Description:

Converts the time to a long.

Returns:

The number of seconds equivalent to the time.

Example:

// The default constructor for PtTime sets the time to the current time.
PtTime aTime,;
cout << (long) aTime << " seconds since midnight!";

Copyright (c) 1996 POET Software, Inc. All rights reserved. Reproduction in whole or in part in any form or medium without the express permission of POET Software, Inc. is prohibited.