CCTimeBase Class Reference

The base class local time generator. Normal time generators should be derived from this. More...

#include <cctime.h>

Inheritance diagram for CCTimeBase:

CCObject SimpleCCObject CCGmtTime CCTime List of all members.

Public Member Functions

 CCTimeBase ()
 CCTimeBase constructor, doesn't do much for the moment.
virtual ~CCTimeBase ()
 Destructor for a CCTimeBase object.
virtual INT32 GetDay ()
 returns the Day of the month, ranges between 1 and 31
virtual INT32 GetDayOfWeek ()
 return the day of the week, 1=Sunday, 2=Monday etc
virtual INT32 GetMonth ()
 Returns the month based on local time, in the range 1 through 12, (1=January).
virtual INT32 GetYear ()
 Returns the year based on local time, in the range 1970 through 2038,.
virtual INT32 GetHour ()
 returns the hour, based on local time, in the range 0 through 23
virtual INT32 Get12Hour ()
virtual INT32 Get24Hour ()
virtual INT32 GetMinute ()
 Returns the minute based on local time, in the range 0 through 59.
virtual INT32 GetSecond ()
 Returns the second based on local time, in the range 0 through 59,.
virtual void GetCurrentTime ()
virtual void ConvertStandardDateAndTime (const String_64 *pFormat, String_256 *pOutput)
 Build a date and time string using the format string provided. Allowable format fields are yr = year mt = month dy = day hr = hours (24 hour clock) mn = minutes sc = seconds th = hours (12 hour clock) pm = am/pm characters %% = % These fields should be embedded in the format string along with other characters eg "%hr/%mn/%sc" = 19/22/33 "%dy/%mt/%yr" = 21/12/1996 "%dy/%mt/%yr - %hr/%mn/%sc" = 21/12/1996 - 19/22/33" "%dy/%mt/%yr - %th.%mn %pm" = 21/12/1996 - 6.45 am.
const CCTimeBaseoperator= (const CCTimeBase &timeSrc)
 Assign one CCTimeBase object to another.

Protected Member Functions

cctimeGetTimeStruct ()
 Return a pointer to our internal time structure for derived classes to use. They should really use the access functions for all but the initialisation of this structure.

Private Attributes

cctime TheTime

Detailed Description

The base class local time generator. Normal time generators should be derived from this.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 131 of file cctime.h.


Constructor & Destructor Documentation

CCTimeBase::CCTimeBase  ) 
 

CCTimeBase constructor, doesn't do much for the moment.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 125 of file cctime.cpp.

00126 {
00127     TheTime.tm_sec  =  0;    // seconds after the minute - [0,59]
00128     TheTime.tm_min  =  0;    // minutes after the hour - [0,59]
00129     TheTime.tm_hour =  0;    // hours since midnight - [0,23]
00130     TheTime.tm_mday =  0;    // day of the month - [1,31]   
00131     TheTime.tm_mon  =  0;    // months since January - [0,11]
00132     TheTime.tm_year =  0;    // years since 1900
00133     TheTime.tm_wday =  0;    // days since Sunday - [0,6]
00134     TheTime.tm_yday =  0;    // days since January 1 - [0,365] 
00135     TheTime.tm_isdst = 0;    // daylight savings time flag 
00136 }

CCTimeBase::~CCTimeBase  )  [virtual]
 

Destructor for a CCTimeBase object.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 149 of file cctime.cpp.

00150 {
00151 }


Member Function Documentation

void CCTimeBase::ConvertStandardDateAndTime const String_64 pFormat,
String_256 pOutput
[virtual]
 

Build a date and time string using the format string provided. Allowable format fields are yr = year mt = month dy = day hr = hours (24 hour clock) mn = minutes sc = seconds th = hours (12 hour clock) pm = am/pm characters %% = % These fields should be embedded in the format string along with other characters eg "%hr/%mn/%sc" = 19/22/33 "%dy/%mt/%yr" = 21/12/1996 "%dy/%mt/%yr - %hr/%mn/%sc" = 21/12/1996 - 19/22/33" "%dy/%mt/%yr - %th.%mn %pm" = 21/12/1996 - 6.45 am.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96
Parameters:
pFormat = a pointer to a format string [INPUTS] pOutput = a pointer to a string to receive the formated date and time Outputs pOutput = contains the formated date and time
Returns:
-

Definition at line 344 of file cctime.cpp.

00345 {
00346     if (pFormat==NULL || pOutput==NULL)
00347         return;
00348 
00349     String_64 Format = (*pFormat);
00350 
00351     const TCHAR percent = TEXT('%');
00352     
00353     // find the number of characters in this string
00354     INT32 ilen = Format.Length();
00355     INT32 ipos = 0;
00356     String_32 tempstr;
00357     INT32 num,az;
00358     TCHAR ch0,ch1,ch2;
00359 
00360     while (ipos<ilen)
00361     {
00362         ch0 = Format[ipos];
00363         if (ch0==percent)
00364         {
00365             if ((ipos+2) < ilen)
00366             {
00367                 ch1 = Format[ipos+1];
00368                 ch2 = Format[ipos+2];
00369 
00370                 if (ch1==percent)
00371                 {
00372                     (*pOutput) += ch1;
00373                     ipos+=1;
00374                 }
00375                 else
00376                 {
00377                     if (ch1==TEXT('p') && ch2==TEXT('m'))
00378                     {
00379                         (*pOutput) += ((GetHour()>12) ? TEXT("pm") : TEXT("am"));
00380                         ipos+=2;
00381                     }
00382                     else
00383                     {
00384                         num = -1;
00385                         az = 0;
00386 
00387                              if (ch1==TEXT('y') && ch2==TEXT('r'))  {   num = (INT32)GetYear() % 100;
00388                                                                         az=1;   }
00389                         else if (ch1==TEXT('m') && ch2==TEXT('t'))  {   num = (INT32)GetMonth();    az=0;   }
00390                         else if (ch1==TEXT('d') && ch2==TEXT('y'))  {   num = (INT32)GetDay();  az=0;   }
00391                         else if (ch1==TEXT('h') && ch2==TEXT('r'))  {   num = (INT32)GetHour(); az=1;   }
00392                         else if (ch1==TEXT('m') && ch2==TEXT('n'))  {   num = (INT32)GetMinute();az=1;  }
00393                         else if (ch1==TEXT('s') && ch2==TEXT('c'))  {   num = (INT32)GetSecond();az=1;  }
00394                         else if (ch1==TEXT('t') && ch2==TEXT('h'))  {   num = (INT32)Get12Hour();az=0;  }
00395 
00396                         if (num>-1)
00397                         {
00398                             Convert::LongToString(num, &tempstr);
00399                             if (az==1 && num<10)
00400                                 (*pOutput)+=TEXT('0');
00401                             (*pOutput) += tempstr;
00402                             ipos+=2;
00403                         }
00404                     }
00405                 }
00406             }
00407             else
00408                 (*pOutput) += ch0;
00409         }
00410         else
00411             (*pOutput) += ch0;
00412 
00413         ipos++;
00414     }
00415 }

INT32 CCTimeBase::Get12Hour  )  [virtual]
 

Definition at line 219 of file cctime.cpp.

00220 {
00221     INT32 t = GetHour();
00222     if (t>12) t-=12;
00223     if (t==0) t+=12;    // adjust for midnight 0 time
00224     return t;
00225 }

INT32 CCTimeBase::Get24Hour  )  [virtual]
 

Definition at line 227 of file cctime.cpp.

00228 {
00229     return GetHour();
00230 }

virtual void CCTimeBase::GetCurrentTime  )  [inline, virtual]
 

Reimplemented in CCTime, and CCGmtTime.

Definition at line 149 of file cctime.h.

00149 {};

INT32 CCTimeBase::GetDay  )  [virtual]
 

returns the Day of the month, ranges between 1 and 31

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 182 of file cctime.cpp.

00183 {
00184     return TheTime.tm_mday;
00185 }

INT32 CCTimeBase::GetDayOfWeek  )  [virtual]
 

return the day of the week, 1=Sunday, 2=Monday etc

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 198 of file cctime.cpp.

00199 {
00200     return TheTime.tm_wday;
00201 }

INT32 CCTimeBase::GetHour  )  [virtual]
 

returns the hour, based on local time, in the range 0 through 23

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 214 of file cctime.cpp.

00215 {
00216     return TheTime.tm_hour;
00217 }

INT32 CCTimeBase::GetMinute  )  [virtual]
 

Returns the minute based on local time, in the range 0 through 59.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 243 of file cctime.cpp.

00244 {
00245     return TheTime.tm_min;
00246 }

INT32 CCTimeBase::GetMonth  )  [virtual]
 

Returns the month based on local time, in the range 1 through 12, (1=January).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Reimplemented in CCTime, and CCGmtTime.

Definition at line 259 of file cctime.cpp.

00260 {
00261     return TheTime.tm_mon;
00262 }

INT32 CCTimeBase::GetSecond  )  [virtual]
 

Returns the second based on local time, in the range 0 through 59,.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 275 of file cctime.cpp.

00276 {
00277     return TheTime.tm_sec;
00278 }

cctime * CCTimeBase::GetTimeStruct  )  [protected]
 

Return a pointer to our internal time structure for derived classes to use. They should really use the access functions for all but the initialisation of this structure.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 165 of file cctime.cpp.

00166 {
00167     return &TheTime;
00168 }

INT32 CCTimeBase::GetYear  )  [virtual]
 

Returns the year based on local time, in the range 1970 through 2038,.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Reimplemented in CCGmtTime.

Definition at line 291 of file cctime.cpp.

00292 {
00293     return TheTime.tm_year;
00294 }

const CCTimeBase & CCTimeBase::operator= const CCTimeBase timeSrc  ) 
 

Assign one CCTimeBase object to another.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/08/96

Definition at line 307 of file cctime.cpp.

00308 {
00309     TheTime = timeSrc.TheTime;
00310     return (*this);
00311 }


Member Data Documentation

cctime CCTimeBase::TheTime [private]
 

Definition at line 158 of file cctime.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:13 2007 for Camelot by  doxygen 1.4.4