version 1.2, 2001/03/23 20:19:20
|
version 1.32, 2002/08/20 17:39:37
|
|
|
//BEGIN_LICENSE |
//%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 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 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// copy of this software and associated documentation files (the "Software"), |
// of this software and associated documentation files (the "Software"), to |
// to deal in the Software without restriction, including without limitation |
// deal in the Software without restriction, including without limitation the |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// and/or sell copies of the Software, and to permit persons to whom the |
// sell copies of the Software, and to permit persons to whom the Software is |
// Software is furnished to do so, subject to the following conditions: |
// furnished to do so, subject to the following conditions: |
|
// |
|
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
|
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
|
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
|
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// |
|
//============================================================================== |
|
// |
|
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// 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) |
|
// Carol Ann Krug Graves, Hewlett-Packard Company |
|
// (carolann_graves@hp.com) |
// | // |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
//%///////////////////////////////////////////////////////////////////////////// |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
|
// DEALINGS IN THE SOFTWARE. |
|
// |
|
//END_LICENSE |
|
//BEGIN_HISTORY |
|
// |
|
// Author: |
|
// |
|
// $Log$ |
|
// Revision 1.2 2001/03/23 20:19:20 mike |
|
// Reformatted documentation. Added a couple of ATTN's |
|
// |
|
// Revision 1.1 2001/02/18 18:39:06 mike |
|
// new |
|
// |
|
// Revision 1.2 2001/02/18 03:02:58 karl |
|
// comment cleanup |
|
// |
|
// Revision 1.1 2001/02/16 02:07:06 mike |
|
// Renamed many classes and headers (using new CIM prefixes). |
|
// |
|
// Revision 1.3 2001/02/06 17:04:03 karl |
|
// add documentation |
|
// |
|
// Revision 1.2 2001/01/24 13:54:09 karl |
|
// Add Doc++ Document Comments |
|
// |
|
// Revision 1.1.1.1 2001/01/14 19:50:41 mike |
|
// Pegasus import |
|
// |
|
// |
|
//END_HISTORY |
|
| |
#ifndef Pegasus_DateTime_h | #ifndef Pegasus_DateTime_h |
#define Pegasus_DateTime_h | #define Pegasus_DateTime_h |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <iostream> |
#include <Pegasus/Common/Array.h> |
|
#include <Pegasus/Common/Linkage.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
/* ATTN: P3. KS Several functions should be added to this class for datetime manipulation |
|
including get and set each subcomponent (year, month, etc), test for equality, |
|
create intervals from absolutes, possibly gett current time, Note that |
|
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 |
is an intrinsic CIM data type which represents the time as a formated |
is an intrinsic CIM data type which represents the time as a formatted |
fixedplength string. |
fixed length string. |
| |
<PRE> | <PRE> |
A date has the following form: | A date has the following form: |
|
|
| |
Where | Where |
| |
yyyy = year (0-1999) |
yyyy = year (1-9999) |
mm = month (1-12) | mm = month (1-12) |
dd = day (1-31) | dd = day (1-31) |
hh = hour (0-23) | hh = hour (0-23) |
mm = minute (0-59) | mm = minute (0-59) |
ss = second (0-59) | ss = second (0-59) |
mmmmmm = microseconds. |
mmmmmm = microseconds |
s = '+' or '-' to represent the UTC sign. |
s = '+' or '-' to represent the UTC sign |
utc = UTC offset (same as GMT offset). |
utc = UTC offset (same as GMT offset) |
| |
An interval has the following form: | An interval has the following form: |
| |
|
|
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> |
| |
|
|
better to think of an interval as specifying time elapsed since | better to think of an interval as specifying time elapsed since |
some event. | some event. |
| |
CIMDateTime objects are constructed from C character strings or from |
CIMDateTime objects are constructed from String objects or from |
other CIMDateTime objects. These character strings must be exactly | other CIMDateTime objects. These character strings must be exactly |
twenty-five characters and conform to one of the forms idententified |
twenty-five characters and conform to one of the forms identified |
above. | above. |
| |
CIMDateTime objects which are not explicitly initialized will be |
CIMDateTime objects that are not explicitly initialized will be |
implicitly initialized with the null time interval: |
implicitly initialized with a zero time interval: |
| |
00000000000000.000000:000 | 00000000000000.000000:000 |
| |
Instances can be tested for nullness with the isNull() method. |
|
|
|
ATTN: Add inequalities. |
|
*/ | */ |
class PEGASUS_COMMON_LINKAGE CIMDateTime | class PEGASUS_COMMON_LINKAGE CIMDateTime |
{ | { |
public: | public: |
| |
enum { FORMAT_LENGTH = 25 }; |
/** Creates a new CIMDateTime object with a zero interval value |
|
|
/// CIMDateTime CIMMethod |
|
CIMDateTime(); |
|
|
|
/** CIMDateTime CIMMethod creates the CIM CIMDateTime from a string |
|
constant. |
|
*/ | */ |
CIMDateTime(const char* str); |
CIMDateTime(); |
| |
/** CIMDateTime CIMMethod - Creates the CIMDateTime instance from another |
/** CIMDateTime - Creates a CIM CIMDateTime instance from a string |
CIMDateTime instance |
constant representing the CIM DateTime-formatted datetime |
|
See the class documentation for CIMDateTime for the definition of the |
|
input string for absolute and interval datetime. |
|
@param str String object containing the CIM DateTime-formatted string |
|
*/ |
|
CIMDateTime(const String & str); |
|
|
|
/** CIMDateTime Create a CIMDateTime instance from another |
|
CIMDateTime object |
|
@param x CIMDateTime object to be copied. |
*/ | */ |
CIMDateTime(const CIMDateTime& x); | CIMDateTime(const CIMDateTime& x); |
| |
/** CIMDateTime method again |
/** DateTime Destructor. */ |
|
~CIMDateTime(); |
|
|
|
/** Assign one DateTime object to another |
|
@param - The DateTime Object to assign |
|
<pre> |
|
CIMDateTime d1; |
|
CIMDateTime d2 = "00000000000000.000000:000"; |
|
d1 = d1; |
|
</pre> |
*/ | */ |
CIMDateTime& operator=(const CIMDateTime& x); | CIMDateTime& operator=(const CIMDateTime& x); |
| |
/** CIMDateTime isNull method - Tests for an all zero date time |
/** toString - Returns the string representing the DateTime value of the |
<PRE> |
CIMDateTime Object. |
CIMDateTime dt; |
|
dt.clear(); |
|
assert(dt.isNull()); |
|
</PRE> |
|
@return This method returns true of the contents are |
|
"00000000000000.000000:000". Else it returns false |
|
*/ | */ |
Boolean isNull() const; |
String toString () const; |
|
|
/// method getString |
|
const char* getString() const; |
|
| |
/** method set - Sets the date time. Creates the CIMDateTime instance from | /** method set - Sets the date time. Creates the CIMDateTime instance from |
the input string constant which must be | the input string constant which must be |
|
|
dt.set("19991224120000.000000+360"); | dt.set("19991224120000.000000+360"); |
</PRE> | </PRE> |
| |
@return On format error, CIMDateTime set throws the exception |
@exception InvalidDateTimeFormatException on format error. |
BadDateTimeFormat |
|
@exception Throws exception BadDateTimeFormat on format error. |
|
*/ | */ |
void set(const char* str); |
void set(const String & str); |
| |
/// CIMDateTime method clear - Clears the datetime class instance. |
/** clear - Clears the datetime class instance. The date time is set to |
|
a zero interval value. |
|
*/ |
void clear(); | void clear(); |
| |
/** CIMDateTime CIMMethod - ATTN: Friend operator Test for CIMDateTime |
/** |
equality |
Get current time as CIMDateTime. The time returned is the local time. |
|
|
|
@return CIMDateTime Contains the current datetime as a CIMDateTime object. |
*/ | */ |
PEGASUS_COMMON_LINKAGE friend Boolean operator==( |
static CIMDateTime getCurrentDateTime(); |
const CIMDateTime& x, |
|
const CIMDateTime& y); |
/** |
|
Computes the difference in microseconds between two CIMDateTime dates or |
|
two CIMDateTime intervals |
|
|
|
@param startTime Contains the start datetime |
|
|
|
@param finishTime Contains the finish datetime |
|
|
|
@return difference Difference between the two datetimes in microseconds |
|
|
|
@exception InvalidDateTimeFormatException If one argument is a datetime |
|
and one is an interval |
|
*/ |
|
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(); |
|
|
|
/** |
|
Compares the CIMDateTime object to another CIMDateTime object for equality |
|
|
|
@return True if the two CIMDateTime objects are equal, |
|
False otherwise |
|
*/ |
|
Boolean equal (const CIMDateTime & x) const; |
| |
private: | private: |
| |
Boolean _set(const char* str); |
CIMDateTimeRep* _rep; |
char _rep[FORMAT_LENGTH + 1]; |
|
|
Boolean _set(const String & dateTimeStr); |
}; | }; |
| |
PEGASUS_COMMON_LINKAGE Boolean operator==( | PEGASUS_COMMON_LINKAGE Boolean operator==( |
const CIMDateTime& x, | const CIMDateTime& x, |
const CIMDateTime& y); | const CIMDateTime& y); |
| |
PEGASUS_COMMON_LINKAGE std::ostream& operator<<( |
#define PEGASUS_ARRAY_T CIMDateTime |
std::ostream& os, |
# include <Pegasus/Common/ArrayInter.h> |
const CIMDateTime& x); |
#undef PEGASUS_ARRAY_T |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |