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.
Files to include | Class declaration | Base class |
poet.hxx | ptcomp.hxx | none |
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()
- PtTime::PtTime(long seconds)
PtTime::PtTime(const PtTime& time)
Each of these is described separately below.
- PtTime::PtTime()
Constructor. Initializes the time to the current system time.
- PtTime::PtTime(long seconds)
Constructor. Initializes the time to the given number of seconds.
- PtTime::PtTime(char h, char m, char s)
Constructor. Initializes the time to the given hour, minutes, and seconds.
- PtTime::PtTime(const PtTime& time)
Copy constructor. Initializes the new time to the value contained in another time.
- PtTime QuittingTime((char) 19, (char) 0, (char) 0);
- PtTime DesiredTime = QuittingTime;
- PtTime::~PtTime()
- char& PtTime::Hour()
A method used to get or set the hour.
The hour member (by reference).
- PtTime time;
- time.Hour() = 3; // setting the hour
- cout << (int) time.Hour(); // reading the hour
The cast in the last line is necessary if the hour is to be printed as an integer.
- char PtTime::Hour() const
A method used to get the hour.
The hour.
- int PtTime::IsTime()
Checks whether the time is valid.
0 | Not a valid time |
Non-zero | Valid time |
- char& PtTime::Minutes(short)
A method used to get or set minutes.
The minutes member (by reference).
- PtTime time;
- time.Minutes() = 3; // setting the minutes
- cout << (int) time.Minutes(); // reading the minutes
The cast in the last line is necessary if minutes is to be printed as an integer.
- char PtTime::Minutes(short) const
The minutes.
- PtTime& PtTime::Now()
- char& PtTime::Seconds(short)
A method used to get or set seconds.
The seconds member (by reference).
- PtTime time;
- time.Seconds() = 3; // Setting seconds
- cout << (int) time.Seconds();// Reading seconds
The cast in the last line is necessary if seconds is to be printed as an integer.
- char PtTime::Seconds(short) const
The seconds.
- PtTime PtTime::operator + (int n)
The result of the addition.
- PtTime PtTime::operator - (PtTime& time) PtTime PtTime::operator - (long seconds)
Subtracts one time from another, returning the difference between the two times.
The result of the subtraction.
- PtTime timeA ( (char) 3, (char) 10, (char) 25);
- PtTime timeB ( (char) 2, (char) 5, (char) 10);
- PtTime result;
- result = timeA - timeB;
- PtTime& PtTime::operator ++ ()
Increments the time. Only the prefix operator has been implemented.
The incremented time.
- PtTIme aTime;
- ++aTime;
- // *not* aTime++;
- PtTime& PtTime::operator -- ()
Decrements the time. Only the prefix operator has been implemented.
The decremented time.
- PtTIme aTime;
- --aTime;
- // *not* aTime--;
- PtTime& PtTime::operator += (long seconds)
The resulting time.
- PtTime aTime, bTime;
- aTime += bTime;
- PtTime& PtTime::operator -= (long seconds)
Subtracts seconds from the time.
The resulting time.
- PtTime aTime;
- aTime -= 10;
- PtTime& PtTime::operator = (const PtTime& )
The resulting time.
- PtTime aTime, bTime;
- aTime = bTime;
- int PtTime::operator < (PtTime& )
0 | Not less than |
Non-zero | Less than |
- PtTime aTime, bTime;
- aTime -= 1;
- if (aTime < bTime)
- cout << "Yup, it really is less than!" << endl;
- int PtTime::operator > (PtTime& )
0 | Not greater than |
Non-zero | Greater than |
- PtTime aTime, bTime;
- aTime += 1;
- if (aTime > bTime)
- cout << "Yup, it really is greater than!" << endl;
- int PtTime::operator == (PtTime& )
0 | Not equal |
Non-zero | Equal |
- PtTime aTime, bTime;
- if (aTime == bTime)
- cout << "Isn't equality great?" << endl;
- int PtTime::operator != (PtTime& )
0 | Not equal |
-1 | This time is less than the parameter |
+1 | This time is greater than the parameter |
- 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()
The number of seconds equivalent to the time.
- // 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.