CIMDateTime Class Reference
#include <CIMDateTime.h>
List of all members.
Detailed Description
The CIMDateTime class represents the CIM datetime data type as a C++ class CIMDateTime. A CIM datetime may contain a time stamp or an interval. CIMDateTime is an intrinsic CIM data type that represents the time as a string with a fixed length.
A time stamp has the following form:
yyyymmddhhmmss.mmmmmmsutc
Where
yyyy = year (1-9999)
mm = month (1-12)
dd = day (1-31)
hh = hour (0-23)
mm = minute (0-59)
ss = second (0-59)
mmmmmm = microseconds
s = '+' or '-' to represent the Coordinated Universal Time (UTC) sign
utc = offset from Coordinated Universal Time (UTC)
(same as Greenwich Mean Time(GMT) offset)
An interval has the following form:
ddddddddhhmmss.mmmmmm:000
Where
dddddddd = days
hh = hours (0-23)
mm = minutes (0-59)
ss = seconds (0-59)
mmmmmm = microseconds
Note: Intervals always end in ":000". This distinguishes intervals from time stamps.
CIMDateTime objects are constructed from String objects or from other CIMDateTime objects. Character strings must be exactly twenty-five characters in length and conform to either the time stamp or interval format.
CIMDateTime objects that are not explicitly initialized will be implicitly initialized with a zero time interval:
00000000000000.000000:000
The following table shows what arithmetic operations are allowed between CIMDateTime types. The entries in the last four columns define the type of the result when the operation, specified in the column header, is performed on operands, of the types specified in the first two columns.
LHS - left hand side TS - time stamp int - integer
RHS - right hand side IV - interval
X - operation not allowed between types
LHS RHS + - * /
_____________________________________________
TS TS X IV X X
TS IV TS TS X X
TS int X X X X
IV IV IV IV X int
IV TS X X X X
IV int X X IV IV
int TS X X X X
int IV X X X X
The relational operators may only operate on two operands of the same type, i.e. two time stamps or two intervals.
Constructor & Destructor Documentation
CIMDateTime::CIMDateTime |
( |
|
) |
|
Creates a new CIMDateTime object with a zero interval value.
CIMDateTime::CIMDateTime |
( |
const String & |
str |
) |
|
Creates a new CIMDateTime object from a string 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.
- Parameters:
-
| str | String object containing the CIMDateTime formatted string. This must contain twenty-five characters. |
- Exceptions:
-
CIMDateTime::CIMDateTime |
( |
Uint64 |
usec, |
|
|
Boolean |
isInterval | |
|
) |
| | |
Creates a CIMDateTime object from an integer.
- Parameters:
-
| usec | For a time stamp, the number of microseconds since the epoch 0/0/0000 (12 am Jan 1, 1BCE); For an interval, the number of microseconds in the interval. |
| isInterval | Specifies whether the CIMDateTime object is to be created as an interval value (true) or a time stamp (false). |
- Exceptions:
-
| DateTimeOutOfRangeException | If the microSec value is too large (greater than 317,455,200,000,000,000 for a time stamps or 8,640,000,000,000,000,000 for an interval). |
| InvalidDateTimeFormatException | If the CIMDateTime object is not formed correctly. |
CIMDateTime::~CIMDateTime |
( |
|
) |
|
Member Function Documentation
void CIMDateTime::clear |
( |
|
) |
|
Clears the datetime class object. The date time is set to a zero interval value.
Boolean CIMDateTime::equal |
( |
const CIMDateTime & |
x |
) |
const |
Compares the CIMDateTime object to another CIMDateTime object for equality.
- Parameters:
-
- Returns:
- true if the two CIMDateTime objects are equal, false otherwise
- Exceptions:
-
static CIMDateTime CIMDateTime::getCurrentDateTime |
( |
|
) |
[static] |
Returns the current local time in a CIMDateTime object.
- Returns:
- CIMDateTime object containing the current local date and time.
Computes the difference in microseconds between two CIMDateTime time stamps or two CIMDateTime intervals.
- Parameters:
-
| startTime | Contains the start datetime. |
| finishTime | Contains the finish datetime. |
- Returns:
- An integer that contains the difference between the two datetime values (in microseconds).
- Exceptions:
-
Boolean CIMDateTime::isInterval |
( |
|
) |
|
Checks whether the datetime is an interval. (This non-const form is maintained for compatibility.)
- Returns:
- True if the datetime is an interval value, false otherwise.
Boolean CIMDateTime::isInterval |
( |
|
) |
const |
Checks whether the datetime is an interval.
- Returns:
- True if the datetime is an interval value, false otherwise.
Boolean CIMDateTime::operator!= |
( |
const CIMDateTime & |
x |
) |
const |
Compare two CIMDateTime objects and returns true if the LHS is not equal to the RHS.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- true if the LHS is not equal to RHS, false otherwise.
- Exceptions:
-
Multiplies a CIMDateTime object by an integer and returns a CIMDateTime object that represents the product.
- Parameters:
-
| x | integer operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of multiplying the calling object by the RHS operand.
- Exceptions:
-
Multiplies a CIMDateTime object by an integer, returns the product and changes the value of the calling object to match the returned product.
- Parameters:
-
| x | integer operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of multiplying the calling object by the RHS operand.
- Exceptions:
-
Adds two CIMDateTime objects and returns a CIMDateTime object that represents the sum.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of adding the calling object to the RHS operand
- Exceptions:
-
Adds two CIMDateTime objects, returns the sum and changes the value of the calling CIMDateTime object to match the return value.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of adding the calling object to the RHS operand
- Exceptions:
-
Subtracts one CIMDateTime object from another and returns a CIMDateTime object that represents the difference.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of subtracting the the RHS object from the calling.
- Exceptions:
-
Subtracts one CIMDateTime object from another, returns the difference and changes the value of the calling CIMDateTime object to match the return value.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of subtracting the object on the RHS from the calling object.
- Exceptions:
-
Uint64 CIMDateTime::operator/ |
( |
const CIMDateTime & |
cdt |
) |
const |
Divides a CIMDateTime object by another CIMDateTime object and returns an integer quotient.
- Parameters:
-
- Returns:
- An integer that is the result of dividing the number of microseconds represented by the calling CIMDateTime object by the number of microseconds represented by the CIMDateTime object on the RHS of the operator.
- Exceptions:
-
CIMDateTime CIMDateTime::operator/ |
( |
Uint64 |
num |
) |
const |
Divides a CIMDateTime object by an integer and returns a CIMDateTime object that represents the quotient.
- Parameters:
-
| num | integer operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of dividing the calling object by the RHS operand.
- Exceptions:
-
Divides a CIMDateTime object by an integer, returns the quotient and changes the value of the calling object to match the returned quotient.
- Parameters:
-
| num | integer operand on the RHS of the operator |
- Returns:
- A CIMDateTime object that is the result of dividing the calling object by the RHS operand.
- Exceptions:
-
Boolean CIMDateTime::operator< |
( |
const CIMDateTime & |
x |
) |
const |
Compare two CIMDateTime objects and returns true if the LHS is less than the RHS.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- true if the LHS is less than the RHS, false otherwise.
- Exceptions:
-
Boolean CIMDateTime::operator<= |
( |
const CIMDateTime & |
x |
) |
const |
Compare two CIMDateTime objects and returns true if the LHS is less than or equal to the RHS.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- true if the LHS is less than or equal to the RHS, false otherwise.
- Exceptions:
-
Assigns one instance of the CIMDateTime object to another.
- Parameters:
-
Boolean CIMDateTime::operator> |
( |
const CIMDateTime & |
x |
) |
const |
Compare two CIMDateTime objects and returns true if the LHS is greater than the RHS.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- true if the LHS is greater than the RHS, false otherwise.
- Exceptions:
-
Boolean CIMDateTime::operator>= |
( |
const CIMDateTime & |
x |
) |
const |
Compare two CIMDateTime objects and returns true if the LHS is greater than or equal to the RHS.
- Parameters:
-
| x | operand on the RHS of the operator |
- Returns:
- true if the LHS is greater than or equal to the RHS, false otherwise.
- Exceptions:
-
void CIMDateTime::set |
( |
const String & |
str |
) |
|
Sets the datetime value from the input parameter.
- Parameters:
-
| str | String containing the new value in the datetime format (specified in the CIMDateTime class description). For example, the following sets the date to December 24, 1999 and time to 12:00 P.M. EST. |
CIMDateTime dt;
dt.set("19991224120000.000000-300");
- Exceptions:
-
Uint64 CIMDateTime::toMicroSeconds |
( |
|
) |
const |
Converts a CIMDateTime object to its microsecond representation.
- Returns:
- Number of microseconds since the epoch (for time stamps) or in a span of time (for intervals).
- Exceptions:
-
String CIMDateTime::toString |
( |
|
) |
const |
Returns a string representing the DateTime value of the CIMDateTime object.
- Returns:
- String representing the DateTime value.
The documentation for this class was generated from the following file: