version 1.48, 2005/05/04 21:38:32
|
version 1.52, 2006/11/10 18:14:57
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// 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 |
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#ifndef Pegasus_DateTime_h |
#ifndef Pegasus_CIMDateTime_h |
#define Pegasus_DateTime_h |
#define Pegasus_CIMDateTime_h |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Array.h> | #include <Pegasus/Common/Array.h> |
|
|
{ | { |
public: | public: |
| |
|
#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES |
|
|
|
/** Wildcard parameter for component-based initializer member functions. |
|
*/ |
|
static const Uint32 WILDCARD; |
|
|
|
#endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */ |
|
|
/** Creates a new CIMDateTime object with a zero interval value. | /** Creates a new CIMDateTime object with a zero interval value. |
*/ | */ |
CIMDateTime(); | CIMDateTime(); |
| |
|
/** Creates a CIMDateTime object from another CIMDateTime object. |
|
@param x Specifies the name of the CIMDateTime object to copy. |
|
*/ |
|
CIMDateTime(const CIMDateTime& x); |
|
|
/** Creates a new CIMDateTime object from a string constant representing | /** Creates a new CIMDateTime object from a string constant representing |
the CIM DateTime formatted datetime. | the CIM DateTime formatted datetime. |
See the class documentation for CIMDateTime for the definition of the | See the class documentation for CIMDateTime for the definition of the |
|
|
*/ | */ |
CIMDateTime(const String & str); | CIMDateTime(const String & str); |
| |
/** Creates a CIMDateTime object from another CIMDateTime object. |
|
@param x Specifies the name of the CIMDateTime object to copy. |
|
*/ |
|
CIMDateTime(const CIMDateTime& x); |
|
|
|
/** Creates a CIMDateTime object from an integer. | /** Creates a CIMDateTime object from an integer. |
@param microSec For a time stamp, the number of microseconds since | @param microSec For a time stamp, the number of microseconds since |
the epoch 0/0/0000 (12 am Jan 1, 1BCE); For an interval, the number | the epoch 0/0/0000 (12 am Jan 1, 1BCE); For an interval, the number |
|
|
@exception InvalidDateTimeFormatException If the CIMDateTime object is | @exception InvalidDateTimeFormatException If the CIMDateTime object is |
not formed correctly. | not formed correctly. |
*/ | */ |
CIMDateTime(Uint64 microSec, Boolean interval); |
CIMDateTime(Uint64 usec, Boolean isInterval); |
|
|
|
#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES |
|
|
|
/** Create datetime time stamp from components. |
|
@param year zero-based year number (or CIMDateTime::WILDCARD) |
|
@param month number from 1 to 12 (or CIMDateTime::WILDCARD) |
|
@param day one-based day of the month (or CIMDateTime::WILDCARD) |
|
@param hours a number from 0 to 23 (or CIMDateTime::WILDCARD) |
|
@param minutes a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param seconds a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param microseconds a number from 0 to 999999 |
|
@param numSignificantMicrosecondDigits the number of decimal digits of |
|
the microseconds parameter (from left to right) that are |
|
significant (all others are wildcarded) or six if they are all |
|
significant. |
|
@param UTF offset in minutes (negative or positive). |
|
@exception DateTimeOutOfRangeException. |
|
*/ |
|
CIMDateTime( |
|
Uint32 year, |
|
Uint32 month, |
|
Uint32 day, |
|
Uint32 hours, |
|
Uint32 minutes, |
|
Uint32 seconds, |
|
Uint32 microseconds, |
|
Uint32 numSignificantMicrosecondDigits, |
|
Sint32 utcOffset); |
|
|
|
/** Create datetime interval from components. |
|
@param days a number from 0 to 99999999 (or CIMDateTime::WILDCARD) |
|
@param hours a number from 0 to 23 (or CIMDateTime::WILDCARD) |
|
@param minutes a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param seconds a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param microseconds a number from 0 to 999999 |
|
@param numSignificantMicrosecondDigits the number of decimal digits of |
|
the microseconds parameter (from left to right) that are |
|
significant (all others are wildcarded) or six if they are all |
|
significant. |
|
@exception DateTimeOutOfRangeException. |
|
*/ |
|
CIMDateTime( |
|
Uint32 days, |
|
Uint32 hours, |
|
Uint32 minutes, |
|
Uint32 seconds, |
|
Uint32 microseconds, |
|
Uint32 numSignificantMicrosecondDigits); |
|
|
|
#endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */ |
| |
/** CIMDateTime destructor. */ | /** CIMDateTime destructor. */ |
~CIMDateTime(); | ~CIMDateTime(); |
|
|
CIMDateTime d2 = "00000000000000.000000:000"; | CIMDateTime d2 = "00000000000000.000000:000"; |
d1 = d2; | d1 = d2; |
</PRE> | </PRE> |
Therefore, d1 is assigned the same "00000000000000.000000:000" value as d2. |
Therefore, d1 is assigned the same "00000000000000.000000:000" value |
|
as d2. |
*/ | */ |
CIMDateTime& operator=(const CIMDateTime& x); | CIMDateTime& operator=(const CIMDateTime& x); |
| |
|
|
*/ | */ |
void set(const String & str); | void set(const String & str); |
| |
|
#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES |
|
|
|
/** Sets the datetime timestamp from individual components. |
|
@param year zero-based year number (or CIMDateTime::WILDCARD) |
|
@param month number from 1 to 12 (or CIMDateTime::WILDCARD) |
|
@param day one-based day of the month (or CIMDateTime::WILDCARD) |
|
@param hours a number from 0 to 23 (or CIMDateTime::WILDCARD) |
|
@param minutes a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param seconds a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param microseconds a number from 0 to 999999 |
|
@param UTF offset in minutes (negative or positive). |
|
@param numSignificantMicrosecondDigits the number of decimal digits of |
|
the microseconds parameter (from left to right) that are |
|
significant (all others are wildcarded) or six if they are all |
|
significant. |
|
@exception DateTimeOutOfRangeException. |
|
*/ |
|
void setTimeStamp( |
|
Uint32 year, |
|
Uint32 month, |
|
Uint32 day, |
|
Uint32 hours, |
|
Uint32 minutes, |
|
Uint32 seconds, |
|
Uint32 microseconds, |
|
Uint32 numSignificantMicrosecondDigits, |
|
Sint32 utcOffset); |
|
|
|
/** Create datetime interval from components. |
|
@param days a number from 0 to 99999999 |
|
@param hours a number from 0 to 23 (or CIMDateTime::WILDCARD) |
|
@param minutes a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param seconds a number from 0 to 59 (or CIMDateTime::WILDCARD) |
|
@param microseconds a number from 0 to 999999 |
|
@param numSignificantMicrosecondDigits the number of decimal digits of |
|
the microseconds parameter (from left to right) that are |
|
significant (all others are wildcarded) or six if they are all |
|
significant. |
|
@exception DateTimeOutOfRangeException. |
|
*/ |
|
void setInterval( |
|
Uint32 days, |
|
Uint32 hours, |
|
Uint32 minutes, |
|
Uint32 seconds, |
|
Uint32 microseconds, |
|
Uint32 numSignificantMicrosecondDigits); |
|
|
|
#endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */ |
|
|
/** Clears the datetime class object. The date time is set to | /** Clears the datetime class object. The date time is set to |
a zero interval value. | a zero interval value. |
*/ | */ |
|
|
/** Checks whether the datetime is an interval. | /** Checks whether the datetime is an interval. |
@return True if the datetime is an interval value, false otherwise. | @return True if the datetime is an interval value, false otherwise. |
*/ | */ |
|
Boolean isInterval() const; |
Boolean isInterval(); | Boolean isInterval(); |
| |
/** Checks whether the datetime is an interval. |
#ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES |
@return True if the datetime is an interval value, false otherwise. |
|
|
/** Checks whether the datetime is a timestamp. |
|
@return True if so. |
*/ | */ |
Boolean isInterval() const; |
Boolean isTimeStamp() const; |
|
|
|
#endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */ |
| |
/** Compares the CIMDateTime object to another CIMDateTime object for | /** Compares the CIMDateTime object to another CIMDateTime object for |
equality. | equality. |
|
|
| |
/** Adds two CIMDateTime objects and returns a CIMDateTime object that | /** Adds two CIMDateTime objects and returns a CIMDateTime object that |
represents the sum. | represents the sum. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return A CIMDateTime object that is the result of adding the calling | @return A CIMDateTime object that is the result of adding the calling |
object to the RHS operand | object to the RHS operand |
@exception DateTimeOutOfRangeException If the operation causes an | @exception DateTimeOutOfRangeException If the operation causes an |
|
|
@exception TypeMismatchException If the operands are not type | @exception TypeMismatchException If the operands are not type |
compatible (see table of operations). | compatible (see table of operations). |
*/ | */ |
CIMDateTime operator+(const CIMDateTime& cDT) const; |
CIMDateTime operator+(const CIMDateTime& x) const; |
| |
/** Adds two CIMDateTime objects, returns the sum and changes | /** Adds two CIMDateTime objects, returns the sum and changes |
the value of the calling CIMDateTime object to match the return value. | the value of the calling CIMDateTime object to match the return value. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return A CIMDateTime object that is the result of adding the calling | @return A CIMDateTime object that is the result of adding the calling |
object to the RHS operand | object to the RHS operand |
@exception DateTimeOutOfRangeException If the operation causes an | @exception DateTimeOutOfRangeException If the operation causes an |
|
|
@exception TypeMismatchException If the operands are not type | @exception TypeMismatchException If the operands are not type |
compatible (see table of operations). | compatible (see table of operations). |
*/ | */ |
CIMDateTime & operator+=(const CIMDateTime& cDT); |
CIMDateTime & operator+=(const CIMDateTime& x); |
| |
/** Subtracts one CIMDateTime object from another and returns a | /** Subtracts one CIMDateTime object from another and returns a |
CIMDateTime object that represents the difference. | CIMDateTime object that represents the difference. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return A CIMDateTime object that is the result of subtracting the | @return A CIMDateTime object that is the result of subtracting the |
the RHS object from the calling. | the RHS object from the calling. |
@exception DateTimeOutOfRangeException If the operation causes an | @exception DateTimeOutOfRangeException If the operation causes an |
|
|
@exception TypeMismatchException If the operands are not type | @exception TypeMismatchException If the operands are not type |
compatible (see table of operations). | compatible (see table of operations). |
*/ | */ |
CIMDateTime operator-(const CIMDateTime& cDT) const; |
CIMDateTime operator-(const CIMDateTime& x) const; |
| |
/** Subtracts one CIMDateTime object from another, returns the difference | /** Subtracts one CIMDateTime object from another, returns the difference |
and changes the value of the calling CIMDateTime object to match the | and changes the value of the calling CIMDateTime object to match the |
return value. | return value. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return A CIMDateTime object that is the result of subtracting the | @return A CIMDateTime object that is the result of subtracting the |
object on the RHS from the calling object. | object on the RHS from the calling object. |
@exception DateTimeOutOfRangeException If the operation causes an | @exception DateTimeOutOfRangeException If the operation causes an |
|
|
@exception TypeMismatchException If the operands are not type | @exception TypeMismatchException If the operands are not type |
compatible (see table of operations). | compatible (see table of operations). |
*/ | */ |
CIMDateTime & operator-=(const CIMDateTime& cDT); |
CIMDateTime & operator-=(const CIMDateTime& x); |
| |
/** Multiplies a CIMDateTime object by an integer and returns a CIMDateTime | /** Multiplies a CIMDateTime object by an integer and returns a CIMDateTime |
object that represents the product. | object that represents the product. |
|
|
@exception TypeMismatchException If the operands are not type | @exception TypeMismatchException If the operands are not type |
compatible (see table of operations). | compatible (see table of operations). |
*/ | */ |
CIMDateTime operator*(Uint64 num) const; |
CIMDateTime operator*(Uint64 x) const; |
| |
/** Multiplies a CIMDateTime object by an integer, returns the product | /** Multiplies a CIMDateTime object by an integer, returns the product |
and changes the value of the calling object to match the returned | and changes the value of the calling object to match the returned |
|
|
@exception TypeMismatchException If the operands are not type | @exception TypeMismatchException If the operands are not type |
compatible (see table of operations). | compatible (see table of operations). |
*/ | */ |
CIMDateTime & operator*=(Uint64 num); |
CIMDateTime & operator*=(Uint64 x); |
| |
/** Divides a CIMDateTime object by an integer and returns a CIMDateTime | /** Divides a CIMDateTime object by an integer and returns a CIMDateTime |
object that represents the quotient. | object that represents the quotient. |
|
|
| |
/** Compare two CIMDateTime objects and returns true if the LHS is | /** Compare two CIMDateTime objects and returns true if the LHS is |
less than the RHS. | less than the RHS. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return true if the LHS is less than the RHS, false otherwise. | @return true if the LHS is less than the RHS, false otherwise. |
@exception DateTimeOutOfRangeException If conversion to UTC (an | @exception DateTimeOutOfRangeException If conversion to UTC (an |
internal operation) causes an overflow condition. | internal operation) causes an overflow condition. |
@exception TypeMismatchException if operands are not of the same | @exception TypeMismatchException if operands are not of the same |
type. | type. |
*/ | */ |
Boolean operator<(const CIMDateTime& cDT) const; |
Boolean operator<(const CIMDateTime& x) const; |
| |
/** Compare two CIMDateTime objects and returns true if the LHS is | /** Compare two CIMDateTime objects and returns true if the LHS is |
less than or equal to the RHS. | less than or equal to the RHS. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return true if the LHS is less than or equal to the RHS, false | @return true if the LHS is less than or equal to the RHS, false |
otherwise. | otherwise. |
@exception DateTimeOutOfRangeException If conversion to UTC (an | @exception DateTimeOutOfRangeException If conversion to UTC (an |
|
|
@exception TypeMismatchException if operands are not of the same | @exception TypeMismatchException if operands are not of the same |
type. | type. |
*/ | */ |
Boolean operator<=(const CIMDateTime& cDT) const; |
Boolean operator<=(const CIMDateTime& x) const; |
| |
/** Compare two CIMDateTime objects and returns true if the LHS is | /** Compare two CIMDateTime objects and returns true if the LHS is |
greater than the RHS. | greater than the RHS. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return true if the LHS is greater than the RHS, false otherwise. | @return true if the LHS is greater than the RHS, false otherwise. |
@exception DateTimeOutOfRangeException If conversion to UTC (an | @exception DateTimeOutOfRangeException If conversion to UTC (an |
internal operation) causes an overflow condition. | internal operation) causes an overflow condition. |
@exception TypeMismatchException if operands are not of the same | @exception TypeMismatchException if operands are not of the same |
type. | type. |
*/ | */ |
Boolean operator>(const CIMDateTime & cDT) const; |
Boolean operator>(const CIMDateTime & x) const; |
| |
/** Compare two CIMDateTime objects and returns true if the LHS is | /** Compare two CIMDateTime objects and returns true if the LHS is |
greater than or equal to the RHS. | greater than or equal to the RHS. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return true if the LHS is greater than or equal to the RHS, false | @return true if the LHS is greater than or equal to the RHS, false |
otherwise. | otherwise. |
@exception DateTimeOutOfRangeException If conversion to UTC (an | @exception DateTimeOutOfRangeException If conversion to UTC (an |
|
|
@exception TypeMismatchException if operands are not of the same | @exception TypeMismatchException if operands are not of the same |
type. | type. |
*/ | */ |
Boolean operator>=(const CIMDateTime & cDT) const; |
Boolean operator>=(const CIMDateTime & x) const; |
| |
/** Compare two CIMDateTime objects and returns true if the LHS is | /** Compare two CIMDateTime objects and returns true if the LHS is |
not equal to the RHS. | not equal to the RHS. |
@param cDT operand on the RHS of the operator |
@param x operand on the RHS of the operator |
@return true if the LHS is not equal to RHS, false otherwise. | @return true if the LHS is not equal to RHS, false otherwise. |
@exception DateTimeOutOfRangeException If conversion to UTC (an | @exception DateTimeOutOfRangeException If conversion to UTC (an |
internal operation) causes an overflow condition. | internal operation) causes an overflow condition. |
@exception TypeMismatchException if operands are not of the same | @exception TypeMismatchException if operands are not of the same |
type. | type. |
*/ | */ |
Boolean operator!=(const CIMDateTime & cDT) const; |
Boolean operator!=(const CIMDateTime & x) const; |
| |
private: | private: |
|
|
CIMDateTimeRep* _rep; | CIMDateTimeRep* _rep; |
Boolean _set(const String & dateTimeStr); |
CIMDateTime(CIMDateTimeRep*); |
enum Field {ONLY_WILD_CARDS, SOME_WILD_CARDS, ONLY_DIGITS, ERR}; |
|
|
|
Field fieldcheck(const String & in_p, String & rep_field); |
|
|
|
Boolean restOfFields(Uint32 start_position,const String & inStr); |
|
|
|
Uint64 _toMicroSeconds(); |
|
|
|
void convertToUTC(); |
|
|
|
void setUtcOffSet(Sint32 utc); |
|
|
|
void insert_WildCard(Uint32 index); |
|
|
|
Uint32 getHighestWildCardPosition(const CIMDateTime & cDT_s); |
|
}; | }; |
| |
/** Compares two CIMDateTime objects and returns true if they represent the | /** Compares two CIMDateTime objects and returns true if they represent the |
|
|
# 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_CIMDateTime_h */ |