(file) Return to CIMDateTime.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/CIMDateTime.cpp between version 1.20 and 1.21

version 1.20, 2002/05/09 21:08:55 version 1.21, 2002/05/14 04:57:48
Line 63 
Line 63 
 static const char _NULL_INTERVAL_TYPE_STRING[] = "00000000000000.000000:000"; static const char _NULL_INTERVAL_TYPE_STRING[] = "00000000000000.000000:000";
 static const char _NULL_DATE_TYPE_STRING[] = "00000000000000.000000-000"; static const char _NULL_DATE_TYPE_STRING[] = "00000000000000.000000-000";
  
   class CIMDateTimeRep
   {
   public:
       enum { FORMAT_LENGTH = 25 };
   
       //
       // Length of the string required to store only the date and time without
       // the UTC sign and UTC offset.
       // Format is yyyymmddhhmmss.
       // Note : The size does not include the null byte.
       //
       enum { DATE_TIME_LENGTH = 14 };
   
       //
       // Length of the string required to store the  formatted date and time
       // Format is yyyy:mm:dd:hh:mm:ss.
       //
       enum { FORMATTED_DATE_TIME = 20 };
   
       char data[FORMAT_LENGTH + 1];
   };
   
   
 CIMDateTime::CIMDateTime() CIMDateTime::CIMDateTime()
 { {
       _rep = new CIMDateTimeRep();
     clear();     clear();
 } }
  
 CIMDateTime::CIMDateTime(const char* str) CIMDateTime::CIMDateTime(const char* str)
 { {
     set(str);      _rep = new CIMDateTimeRep();
       if (!_set(str))
       {
           delete _rep;
           throw BadDateTimeFormat();
       }
 } }
  
 CIMDateTime::CIMDateTime(const CIMDateTime& x) CIMDateTime::CIMDateTime(const CIMDateTime& x)
 { {
     memcpy(_rep, x._rep, sizeof(_rep));      _rep = new CIMDateTimeRep();
       memcpy(_rep->data, x._rep->data, sizeof(_rep->data));
 } }
  
 CIMDateTime& CIMDateTime::operator=(const CIMDateTime& x) CIMDateTime& CIMDateTime::operator=(const CIMDateTime& x)
 { {
     if (&x != this)     if (&x != this)
         memcpy(_rep, x._rep, sizeof(_rep));          memcpy(_rep->data, x._rep->data, sizeof(_rep->data));
  
     return *this;     return *this;
 } }
  
 CIMDateTime::~CIMDateTime() CIMDateTime::~CIMDateTime()
 { {
       delete _rep;
 } }
  
 Boolean CIMDateTime::isNull() const Boolean CIMDateTime::isNull() const
 { {
     return strcmp(_rep, _NULL_INTERVAL_TYPE_STRING) == 0;      return strcmp(_rep->data, _NULL_INTERVAL_TYPE_STRING) == 0;
 } }
  
 const char* CIMDateTime::getString() const const char* CIMDateTime::getString() const
 { {
     return _rep;      return _rep->data;
 } }
  
 void CIMDateTime::clear() void CIMDateTime::clear()
 { {
     strcpy(_rep, _NULL_INTERVAL_TYPE_STRING);      strcpy(_rep->data, _NULL_INTERVAL_TYPE_STRING);
 } }
  
 Boolean CIMDateTime::_set(const char* str) Boolean CIMDateTime::_set(const char* str)
Line 111 
Line 142 
  
     // Be sure the incoming string is the proper length:     // Be sure the incoming string is the proper length:
  
     if (strlen(str) != FORMAT_LENGTH)      if (strlen(str) != CIMDateTimeRep::FORMAT_LENGTH)
         return false;         return false;
  
     // Determine the type (date or interval); examine the 21st character;     // Determine the type (date or interval); examine the 21st character;
Line 132 
Line 163 
  
     // Check to see if other characters are digits:     // Check to see if other characters are digits:
  
     for (Uint32 i = 0; i < FORMAT_LENGTH; i++)      for (Uint32 i = 0; i < CIMDateTimeRep::FORMAT_LENGTH; i++)
     {     {
         if (i != DOT_OFFSET && i != SIGN_OFFSET && !isdigit(str[i]))         if (i != DOT_OFFSET && i != SIGN_OFFSET && !isdigit(str[i]))
             return false;             return false;
Line 181 
Line 212 
     if (seconds > 59)     if (seconds > 59)
         return false;         return false;
  
     memcpy(_rep, str, sizeof(_rep));      memcpy(_rep->data, str, sizeof(_rep->data));
  
     return true;     return true;
 } }
Line 192 
Line 223 
         throw BadDateTimeFormat();         throw BadDateTimeFormat();
 } }
  
   CIMDateTime CIMDateTime::clone() const
   {
       return CIMDateTime(*this);
   }
   
 PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const CIMDateTime& x) PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const CIMDateTime& x)
 { {
     return os << x.getString();     return os << x.getString();
Line 199 
Line 235 
  
 Boolean operator==(const CIMDateTime& x, const CIMDateTime& y) Boolean operator==(const CIMDateTime& x, const CIMDateTime& y)
 { {
     return memcmp(x._rep, y._rep, sizeof(x._rep)) == 0;      return memcmp(x._rep->data, y._rep->data, sizeof(x._rep->data)) == 0;
 } }
  
 void CIMDateTime::formatDateTime(char* dateTimeStr, tm* tm) void CIMDateTime::formatDateTime(char* dateTimeStr, tm* tm)
Line 359 
Line 395 
     //     //
     // Copy only the Start date and time in to the dateTimeOnly string     // Copy only the Start date and time in to the dateTimeOnly string
     //     //
     dateTimeOnly = new char [FORMATTED_DATE_TIME];      dateTimeOnly = new char [CIMDateTimeRep::FORMATTED_DATE_TIME];
     strncpy( dateTimeOnly, startDateTimeCString, DATE_TIME_LENGTH );      strncpy( dateTimeOnly, startDateTimeCString, CIMDateTimeRep::DATE_TIME_LENGTH );
     dateTimeOnly[DATE_TIME_LENGTH] = 0;      dateTimeOnly[CIMDateTimeRep::DATE_TIME_LENGTH] = 0;
     formatDateTime(dateTimeOnly ,&tmvalStart);     formatDateTime(dateTimeOnly ,&tmvalStart);
  
     //     //
     // Copy only the Finish date and time in to the dateTimeOnly string     // Copy only the Finish date and time in to the dateTimeOnly string
     //     //
     strncpy( dateTimeOnly, finishDateTimeCString, DATE_TIME_LENGTH );      strncpy( dateTimeOnly, finishDateTimeCString, CIMDateTimeRep::DATE_TIME_LENGTH );
     dateTimeOnly[DATE_TIME_LENGTH] = 0;      dateTimeOnly[CIMDateTimeRep::DATE_TIME_LENGTH] = 0;
     formatDateTime( dateTimeOnly, &tmvalFinish );     formatDateTime( dateTimeOnly, &tmvalFinish );
  
     // Convert local time to seconds since the epoch     // Convert local time to seconds since the epoch


Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2