version 1.12, 2002/02/18 13:58:02
|
version 1.24, 2002/05/14 04:57:48
|
|
|
// Author: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: Karl Schopmeyer(k.schopmeyer@opengroup.org) | // Modified By: Karl Schopmeyer(k.schopmeyer@opengroup.org) |
|
// Sushma Fernandes, Hewlett Packard Company |
|
// (sushma_fernandes@hp.com) |
|
// Roger Kumpf, Hewlett Packard Company (roger_kumpf@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Array.h> | #include <Pegasus/Common/Array.h> |
|
#include <time.h> |
|
#ifdef PEGASUS_INTERNALONLY |
#include <iostream> | #include <iostream> |
|
#endif |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
/* ATTN: P3. Several functions should be added to this class for datetime manipulation |
/* ATTN: P3. KS Several functions should be added to this class for datetime manipulation |
including get and set each subcomponent (year, month, etc). isInterval, test for equality, |
including get and set each subcomponent (year, month, etc), test for equality, |
create intervals from absolutes, possibly gett current time, Note that | create intervals from absolutes, possibly gett current time, Note that |
the Java rep is probably tostring, not get string, | the Java rep is probably tostring, not get string, |
*/ | */ |
| |
|
class CIMDateTimeRep; |
|
|
/** | /** |
The CIMDateTime class represents the CIM datetime data type as a C++ class | The CIMDateTime class represents the CIM datetime data type as a C++ class |
CIMDateTime. A CIM datetime may contain a date or an interval. CIMDateTime | CIMDateTime. A CIM datetime may contain a date or an interval. CIMDateTime |
|
|
Where | Where |
| |
dddddddd = days | dddddddd = days |
hh = hours |
hh = hours (0-23) |
mm = minutes |
mm = minutes (0-59) |
ss = seconds |
ss = seconds (0-59) |
mmmmmm = microseconds | mmmmmm = microseconds |
</PRE> | </PRE> |
| |
|
|
{ | { |
public: | public: |
| |
enum { FORMAT_LENGTH = 25 }; |
|
|
|
/** Create a new CIMDateTime object with NULL DateTime definition. | /** Create a new CIMDateTime object with NULL DateTime definition. |
*/ | */ |
CIMDateTime(); | CIMDateTime(); |
|
|
CIMDateTime(const CIMDateTime& x); | CIMDateTime(const CIMDateTime& x); |
| |
/** DateTime Destructor. */ | /** DateTime Destructor. */ |
~CIMDateTime() { } |
~CIMDateTime(); |
| |
/** Assign one DateTime object to another | /** Assign one DateTime object to another |
@param - The DateTime Object to assign | @param - The DateTime Object to assign |
|
|
*/ | */ |
void clear(); | void clear(); |
| |
|
/** Makes a deep copy (clone) of the given object. */ |
|
CIMDateTime clone() const; |
|
|
|
/** |
|
Get current time as CIMDateTime. The time returned is the local time. |
|
|
|
@return CIMDateTime Contains the current datetime as a CIMDateTime object. |
|
|
|
Note: Original code was taken from OperationSystem::getLocalDateTime() |
|
*/ |
|
static CIMDateTime getCurrentDateTime(); |
|
|
|
/** |
|
Get the difference between two CIMDateTimes. This function computes the |
|
difference between two datetimes or between two intervals. The result |
|
is truncated and returned as the number of seconds. |
|
|
|
@param startTime Contains the start time. |
|
|
|
@param finishTime Contains the finish time. |
|
|
|
@return difference Difference between the two datetimes in seconds. |
|
|
|
@throws BadFormat |
|
|
|
*/ |
|
static Sint64 getDifference(CIMDateTime startTime, CIMDateTime finishTime); |
|
|
|
/** |
|
Checks whether the datetime is an interval. |
|
|
|
@return isInterval True if the datetime is an interval, else false |
|
*/ |
|
Boolean isInterval(); |
|
|
|
private: |
|
|
|
CIMDateTimeRep* _rep; |
|
|
|
#ifdef PEGASUS_INTERNALONLY |
|
Boolean _set(const char* str); |
|
|
|
/** |
|
This function extracts the different components of the date and time |
|
from the string passed and assigns it to the tm structure. |
|
|
|
@param dateTimeStr Contains the string to be assigned. |
|
|
|
@param tm Contains the tm structure to be updated. |
|
*/ |
|
static void formatDateTime(char* dateTime, tm* tm); |
|
#endif |
|
|
/** CIMDateTime - ATTN: Friend operator Test for CIMDateTime | /** CIMDateTime - ATTN: Friend operator Test for CIMDateTime |
equality | equality |
*/ | */ |
PEGASUS_COMMON_LINKAGE friend Boolean operator==( | PEGASUS_COMMON_LINKAGE friend Boolean operator==( |
const CIMDateTime& x, | const CIMDateTime& x, |
const CIMDateTime& y); | const CIMDateTime& y); |
|
|
private: |
|
|
|
Boolean _set(const char* str); |
|
char _rep[FORMAT_LENGTH + 1]; |
|
}; | }; |
| |
PEGASUS_COMMON_LINKAGE Boolean operator==( | PEGASUS_COMMON_LINKAGE Boolean operator==( |
const CIMDateTime& x, | const CIMDateTime& x, |
const CIMDateTime& y); | const CIMDateTime& y); |
| |
|
#ifdef PEGASUS_INTERNALONLY |
PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<( | PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<( |
PEGASUS_STD(ostream)& os, | PEGASUS_STD(ostream)& os, |
const CIMDateTime& x); | const CIMDateTime& x); |
|
#endif |
| |
#define PEGASUS_ARRAY_T CIMDateTime | #define PEGASUS_ARRAY_T CIMDateTime |
# include "ArrayInter.h" | # include "ArrayInter.h" |