version 1.39.4.1, 2004/11/05 18:16:21
|
version 1.40, 2004/08/25 00:14:24
|
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
//============================================================================== | //============================================================================== |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By:Willis White (whiwill@ibm.com) PEP #192 - changed CIMDateTimeRep, |
|
// added CIMDateTime::toMicroSeconds() and added sub-classes |
|
// dtInterval and dtTimeStamp. |
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Array.h> | #include <Pegasus/Common/Array.h> |
#include <Pegasus/Common/Linkage.h> | #include <Pegasus/Common/Linkage.h> |
#include <math.h> |
|
//#include <Pegasus/Common/XmlWriter.h> |
|
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
/* the CIMDateTimeRep class holds the data for the CIMDateTime class as it's protected |
class CIMDateTimeRep; |
data members.It also allows for "setting" and "getting" of individual components of |
|
date time. |
|
*/ |
|
class CIMDateTimeRep |
|
{ |
|
public: |
|
String microSec; |
|
String seconds; |
|
String minutes; |
|
String hours; |
|
String days; |
|
String month; |
|
String year; |
|
String utcOffSet; |
|
|
|
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 buffer_day [5]; |
|
// sprintf(yearbuf, "%4d", (days_rem+1)); // day of the month is never 0 (1-31) |
|
// ye_mo_da = ye_mo.append(buffer_day); |
|
|
|
|
|
char data[FORMAT_LENGTH + 1]; |
|
|
|
|
|
Uint64 getMicroSec(); |
|
Uint64 getSeconds(); |
|
Uint64 getMinutes(); |
|
Uint64 getHours(); |
|
Uint64 getDays(); |
|
Uint64 getMonth(); |
|
Uint64 getYear(); |
|
Uint64 getUtcOffSet(); |
|
|
|
Uint16 set_microSec(String & mS); |
|
void set_seconds(String sec); |
|
void set_minutes(String min); |
|
void set_hours(String ho); |
|
void set_days(String da); |
|
void set_month(String mon); |
|
void set_year(String ye); |
|
Boolean set_utcOffSet(String uOff); |
|
void set_data(String vlaue, Uint32 index, Uint32 size); |
|
|
|
void copy(CIMDateTimeRep * cTR); |
|
|
|
}; |
|
|
|
|
|
|
|
/**************************************************************************** |
|
| |
|
/** |
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 |
is an intrinsic CIM data type that represents the time as a string with a | is an intrinsic CIM data type that represents the time as a string with a |
|
|
*/ | */ |
CIMDateTime(const CIMDateTime& x); | CIMDateTime(const CIMDateTime& x); |
| |
/* Creates a CIMDateTime object from from integer. |
|
@pram microSec is the number of micro Seconds in the epoch 0/0/000 (12 am Jan 1, 1BCE) |
|
@parm interval tells what type will be created. If true an Interval will be created, |
|
if false a time stamp will be created. |
|
*/ |
|
CIMDateTime(Uint64 microSec, Boolean interval); |
|
|
|
/** CIMDateTime destructor. */ | /** CIMDateTime destructor. */ |
~CIMDateTime(); | ~CIMDateTime(); |
| |
|
|
@param startTime Contains the start datetime. | @param startTime Contains the start datetime. |
@param finishTime Contains the finish datetime. | @param finishTime Contains the finish datetime. |
@return Integer that contains the difference between the two datetime values | @return Integer that contains the difference between the two datetime values |
in microseconds is the epoch (UTC). |
in microseconds. |
@exception InvalidDateTimeFormatException If one argument uses the interval | @exception InvalidDateTimeFormatException If one argument uses the interval |
format and the other uses the string format. | format and the other uses the string format. |
|
@exception DateTimeOutOfRangeException If datetime is outside the allowed |
************************************************************************************* |
range. |
Take out |
|
|
|
|
|
@exception DateTimeOutOfRangeException If differance is negative. |
|
|
|
| |
Note: The behavior on HP-UX and Windows platform is to throw an exception | Note: The behavior on HP-UX and Windows platform is to throw an exception |
when the dates are out of range. Red Hat Linux platform normalizes the | when the dates are out of range. Red Hat Linux platform normalizes the |
|
|
On Windows platform, the approximate range is between 1970 to 2038. | On Windows platform, the approximate range is between 1970 to 2038. |
| |
On Red Hat Linux platform the approximate range is between 1901 and 2038. | On Red Hat Linux platform the approximate range is between 1901 and 2038. |
************************************************************************************* |
|
*/ | */ |
static Sint64 getDifference(const CIMDateTime& startTime, const CIMDateTime& finishTime); |
static Sint64 getDifference(CIMDateTime startTime, CIMDateTime finishTime); |
| |
/** Checks whether the datetime is an interval. | /** Checks whether the datetime is an interval. |
@return True if the datetime is an interval; otherwise, false. | @return True if the datetime is an interval; otherwise, false. |
*/ | */ |
Boolean isInterval() const; |
Boolean isInterval(); |
| |
/** Compares the CIMDateTime object to another CIMDateTime object for | /** Compares the CIMDateTime object to another CIMDateTime object for |
equality. | equality. |
|
|
*/ | */ |
Boolean equal (const CIMDateTime & x) const; | Boolean equal (const CIMDateTime & x) const; |
| |
/*Converts a CIMDateTime object to it's microsecond representaion*/ |
private: |
Uint64 toMicroSeconds(); |
|
|
|
/* Arithmetic operators |
|
*/ |
|
const CIMDateTime operator+(const CIMDateTime & cDT); |
|
void operator+=(const CIMDateTime & cDT); |
|
|
|
const CIMDateTime operator-(const CIMDateTime & cDT); |
|
void operator-=(const CIMDateTime & cDT); |
|
|
|
const CIMDateTime operator*(Uint64 num); |
|
void operator*=(Uint64 num); |
|
|
|
|
|
const CIMDateTime operator/(Uint64 num); |
|
void operator/=(Uint64 num); |
|
|
|
Uint64 operator/(const CIMDateTime & cdt); |
|
|
|
/* Relational operators |
|
*/ |
|
const Boolean operator<(const CIMDateTime & cDT); |
|
const Boolean operator<=(const CIMDateTime & cDT); |
|
|
|
const Boolean operator>(const CIMDateTime & cDT); |
|
const Boolean operator>=(const CIMDateTime & cDT); |
|
|
|
const Boolean operator!=(const CIMDateTime & cDT); |
|
|
|
|
|
|
|
protected: //commented out for testing purposes |
|
| |
CIMDateTimeRep* _rep; | CIMDateTimeRep* _rep; |
Boolean _set(const String & dateTimeStr); | Boolean _set(const String & dateTimeStr); |
|
|
/* checks to make sure the format of a particulatr field in the DateTime string is correct. |
|
Returns |
|
0 - field contains all wild cards |
|
1 - field contains some wild cards (error) |
|
2 - field contains only digits |
|
*/ |
|
Uint64 fieldcheck(String & in_p, String & rep_field); |
|
|
|
/* check the micro Seconds field for format errors |
|
*/ |
|
Uint64 CIMDateTime::microSecheck(String & in_p); |
|
|
|
/* if a field has a wild card then all the fields with lower significance should have wild cards. This |
|
method makes sure of this. |
|
*/ |
|
Boolean restOfFields(Uint32 start_position,const String inStr); |
|
|
|
Uint64 _toMicroSeconds(); |
|
|
|
/* converts time stamps to thier UTC (GMT) representaion. For intervals it just retruns a copy of |
|
calling program |
|
*/ |
|
CIMDateTime normalizer(); |
|
|
|
/* sets the utc offf set of the CIMDateTime object. This method does not change the value |
|
of object, it only converts the representaion form UTC (GMT) to the time zonne spcified. |
|
@parm cdt TimeStamp object that will be converted |
|
@parm uct uct offset in minutes that represents the time zone to be converted to |
|
Retruns a copy of the calling object modified to represent the same time in a differnet time zone. |
|
*/ |
|
CIMDateTime setUctOffSet(Sint32 utc); |
|
|
|
/*inserts wild cards into CIMDateTime object. |
|
@parm index - position to start placing wild card charicters |
|
@parm cdt - object to be modified |
|
Returns a copy of calling object with wild cards starting at position index |
|
@exception InvalidDateTimeFormatException because of invalid index (see rules for wild cards) |
|
*/ |
|
CIMDateTime insert_WildCard(Uint32 index); |
|
|
|
Uint32 getHighestWildCardPosition(CIMDateTime & cDT_s); |
|
|
|
|
|
}; | }; |
/** | /** |
Add documentation here. | Add documentation here. |
|
|
# include <Pegasus/Common/ArrayInter.h> | # include <Pegasus/Common/ArrayInter.h> |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |
| |
|
|
|
|
|
|
|
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_DateTime_h */ | #endif /* Pegasus_DateTime_h */ |