version 1.16, 2002/04/19 12:09:26
|
version 1.27, 2002/06/03 19:33:29
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
|
// The Open Group, Tivoli Systems |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// 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 |
// Modified By: Sushma Fernandes, Hewlett Packard Company |
|
// (sushma_fernandes@hp.com) | // (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 <iostream> |
|
|
|
#include <time.h> | #include <time.h> |
|
#ifdef PEGASUS_INTERNALONLY |
|
#include <iostream> |
|
#endif |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
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 |
|
|
{ | { |
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 always in UTC format. |
Get current time as CIMDateTime. The time returned is the local time. |
| |
@return CIMDateTime Contains the current datetime as a CIMDateTime object. | @return CIMDateTime Contains the current datetime as a CIMDateTime object. |
| |
|
|
static CIMDateTime getCurrentDateTime(); | static CIMDateTime getCurrentDateTime(); |
| |
/** | /** |
Get the difference between two CIMDateTimes. |
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 startTime Contains the start time. |
| |
|
|
@throws BadFormat | @throws BadFormat |
| |
*/ | */ |
static Real64 getDifference(CIMDateTime startTime, CIMDateTime finishTime); |
static Sint64 getDifference(CIMDateTime startTime, CIMDateTime finishTime); |
| |
/** | /** |
Checks whether the datetime is an interval. | Checks whether the datetime is an interval. |
|
|
*/ | */ |
Boolean isInterval(); | Boolean isInterval(); |
| |
/** CIMDateTime - ATTN: Friend operator Test for CIMDateTime |
|
equality |
|
*/ |
|
PEGASUS_COMMON_LINKAGE friend Boolean operator==( |
|
const CIMDateTime& x, |
|
const CIMDateTime& y); |
|
|
|
private: | private: |
| |
// |
CIMDateTimeRep* _rep; |
// 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 }; |
|
| |
Boolean _set(const char* str); | Boolean _set(const char* str); |
| |
char _rep[FORMAT_LENGTH + 1]; |
|
|
|
/** | /** |
This function extracts the different components of the date and time | This function extracts the different components of the date and time |
from the string passed and assigns it to the tm structure. | from the string passed and assigns it to the tm structure. |
|
|
@param tm Contains the tm structure to be updated. | @param tm Contains the tm structure to be updated. |
*/ | */ |
static void formatDateTime(char* dateTime, tm* tm); | static void formatDateTime(char* dateTime, tm* tm); |
|
|
|
/** CIMDateTime - ATTN: Friend operator Test for CIMDateTime |
|
equality |
|
*/ |
|
PEGASUS_COMMON_LINKAGE friend Boolean operator==( |
|
const CIMDateTime& x, |
|
const CIMDateTime& y); |
}; | }; |
| |
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 <Pegasus/Common/ArrayInter.h> |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |