Declared in: CTime.h
Library: Chronology.so
This class provides a huge amount of functions, most of them overloaded operators, that allow calculating times with ease.
CTime() CTime(int32 seconds) CTime(int32 days, int32 hour, int32 minute, int32 second) CTime(const char *timestr) // *NOT IMPLEMENTED YET* CTime(const CTime &time)
This creates an instance of the CTime class and initialises with the current time, if no parameter was given.
The seconds can be any int32 value. The class initialises itself by correctly splitting seconds up into minutes, hours and days. Thus by giving seconds = -1 you can initialise the object with "-1 day, 23:59:59", if you specify seconds = -3600, the object would represent "-1 day, 23:00:00". Specifying seconds = 86401 would result in "1 day, 00:00:01".
With the day, hour, minute, second constructor you can give all values at once, any overflow will correctly be translated, thus, if you give hour = 25 the day will be added +1 and the hour will be "1";
The constructor that wants a const char* is not currently implemented, so don't use it!
The &time is another CTime instance that will be copied into the new object.
After the object is constructed, day may be any int32, hour is between 0 and 23, minute and second are between 0 and 59. Any function of the CTime class leaves the object in this valid state, thus always correctly recalculating out-of-range values.
~CTime()
This one is not existent, if you write delete myCTime;, the default destructor will be used.
int32 Day(int32 day) int32 Hour(int32 hour) int32 Minute(int32 minute) int32 Second(int32 second)
This functions set the value to the new one and return it. If a value is out of range, the other values will be recalculated, so that every value lies within the legal range. Nothing more should be to say.
int32 Day() int32 Hour() int32 Minute() int32 Second()
These simply return the corresponding value, that lies in the allowed range.
int32 AsSeconds()
This function returns the whole information of the object in an int32 as seconds. Thus it's like: Day()*86400+Hour()*3600+Minute()*60+Second();
Copies day and time to another CTime object.
CTime t1, t2( 6345 ); t1 = t2; // now t1 contains 6345 seconds
Add a CTime to another.
CTime t1, t2( 1 ), t3; t1 += CTime( 0,1,0,0 ); // add 1 hour to t1 (t1 = current time+1h); t3 = t1 + t2; // add another second to t1 and save result in t3;
Subtract a CTime from another. No example needed.
Multiplies a time with a constant value.
CTime t1(0,0,5,0); t1 *= 3; // t1 now contains 15 minutes t1 = t1 * 2; // and now 30 minutes
Divides a CTime through a certain value. If you divide through zero, this will not cause an error, but set the result to 0.
CTime t1( 0,6,30,30 ), t2( 0,3,15,15 ); t1 /= 2; // does the same as t1 = t1/2; // here is a bug: t2 /=2; // same as t2 = t2/2; // this will currently result in a CTime( 0,1,7,7 ), and not in CTime( 1, 37, 37 );
Lets you test if two CTime objects are identical or not. No example this time.
Lets you test whether the first CTime is bigger (or after) the second CTime. Again no examples. I think you can figure it out yourself.
Lets you test whether the first CTime is lower (or before) the second CTime. And, you knew it, no examples.
The Cronology Library, in lovely HTML, for BeOS Release 4.
Copyright © 1999 Michael Praschl. All rights reserved.
Last modified: 17. Feb 1999