本文整理汇总了C++中CIMDateTime类的典型用法代码示例。如果您正苦于以下问题:C++ CIMDateTime类的具体用法?C++ CIMDateTime怎么用?C++ CIMDateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIMDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CIMDateTime
Boolean OperatingSystem::getLastBootUpTime(CIMDateTime& lastBootUpTime)
{
Uint64 sysUpTime = 0;
if(getSystemUpTime(sysUpTime))
{
// convert sysUpTime to microseconds
sysUpTime *= (1000 * 1000);
CIMDateTime currentTime = CIMDateTime::getCurrentDateTime();
CIMDateTime bootTime =
CIMDateTime(currentTime.toMicroSeconds() - sysUpTime, false);
// adjust UTC offset
String s1 = currentTime.toString();
String s2 = bootTime.toString();
s2[20] = s1[20];
s2[21] = s1[21];
s2[22] = s1[22];
s2[23] = s1[23];
lastBootUpTime = CIMDateTime(s2);
return true;
}
return false;
}
示例2: goodLocalDateTime
/**
goodLocalDateTime method of SunOS OS Provider Test Client
Uses the CIMOM getCurrentDateTime function and checks that the
current time from the instance is within one hour of that time.
*/
Boolean OSTestClient::goodLocalDateTime(
const CIMDateTime <ime,
Boolean verbose)
{
if (verbose)
cout<<"Checking LocalDateTime " << ltime.toString() << endl;
CIMDateTime currentDT = CIMDateTime::getCurrentDateTime();
Sint64 raw_delta;
try
{
raw_delta = CIMDateTime::getDifference(ltime, currentDT);
}
catch(DateTimeOutOfRangeException &e)
{
cout << "Error : " << e.getMessage() << endl;
exit;
}
Uint64 delta = labs(raw_delta);
if (verbose) {
cout<<" Should be close to " << currentDT.toString() << endl;
printf( " Delta should be within 360 seconds, is %lld\n",delta);
fflush(stdout);
}
// arbitrary choice of expecting them to be within 360 seconds
return (delta < 360000000);
}
示例3: goodInstallDate
/*
GoodInstallDate method for the OS Provider Test Client
Checks the specified value against the expected value and
returns TRUE if the same, else FALSE
*/
Boolean OSTestClient::goodInstallDate(const CIMDateTime &idate,
Boolean verbose)
{
if (verbose)
cout<<"Checking InstallDate " << idate.toString() << endl;
return false; // not implemented for SunOS, fail if there
}
示例4: goodLocalDateTime
Boolean OSTestClient::goodLocalDateTime(const CIMDateTime <ime,
Boolean verbose)
{
if (verbose)
cout<<"Checking LocalDateTime " << ltime.toString() << endl;
cout<<"- No check written for LocalDateTime " << endl;
return true;
}
示例5: goodInstallDate
/*
GoodInstallDate method for the OS Provider Test Client
Checks the specified value against the expected value and
returns TRUE if the same, else FALSE
*/
Boolean OSTestClient::goodInstallDate(const CIMDateTime &idate,
Boolean verbose)
{
if (verbose)
cout<<"Checking InstallDate " << idate.toString() << endl;
cout<<"- No check written for InstallDate " << endl;
return true;
}
示例6: toMicroSecondString
String WsmUtils::toMicroSecondString(const CIMDateTime &rep)
{
const Uint32 strDurationLength=26;
Uint64 duration = rep.toMicroSeconds();
Uint32 outputLength = 0;
char buffer[strDurationLength];
const char* output = Uint64ToString(buffer, duration, outputLength);
return String(output, outputLength);
}
示例7: goodCurrentTimeZone
/**
goodCurrentTimeZone method of SunOS OS Provider Test Client
Expect the timezone now to be identical to that returned.
*/
Boolean OSTestClient::goodCurrentTimeZone(const Sint16 &tz, Boolean verbose)
{
if (verbose)
cout<<"Checking CurrentTimeZone " << tz << endl;
CIMDateTime currentDT = CIMDateTime::getCurrentDateTime();
String ds = currentDT.toString(); // want timezone
// cheat here since we know the position of the timezone info
// subtracting '0' gets us the number from the ASCII, while
// the multiplies do our shifts and we use the sign appropriately
Sint32 calctz = ((ds[22]-'0') * 100 +
(ds[23]-'0') * 10 +
(ds[24]-'0')) *
(ds[21]=='-'?-1:1);
if (verbose)
cout << " Should be " << calctz << endl;
return (tz == calctz);
}
示例8: Str
Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
示例9: StrictWeakOrdering
bool operator<(const CIMDateTime& x, const CIMDateTime& y)
{
// see if they both the same type (intervals or date/times) or are different types.
if (x.isInterval() ^ y.isInterval())
{
// they're different. We define an interval to be < a date/time
return x.isInterval();
}
else
{
if (x.isInterval())
{
// both intervals
return StrictWeakOrdering(
x.getDays(), y.getDays(),
x.getHours(), y.getHours(),
x.getMinutes(), y.getMinutes(),
x.getSeconds(), y.getSeconds(),
x.getMicroSeconds(), y.getMicroSeconds());
}
else
{
// they're both date/times
return StrictWeakOrdering(
getMagnitude(x), getMagnitude(y),
x.getMicroSeconds(), y.getMicroSeconds());
}
}
}
示例10: switch
PEGASUS_NAMESPACE_BEGIN
Boolean WQLInstancePropertySource::getValue(
const CIMName& propertyName,
WQLOperand& value) const
{
unsigned int pos=ci.findProperty(propertyName);
if (pos==PEG_NOT_FOUND) return false;
CIMValue val=ci.getProperty(pos).getValue();
CIMType type=val.getType();
if (val.isNull())
{
value=WQLOperand();
return true;
}
if (val.isArray()) return false;
switch (type)
{
case CIMTYPE_UINT8:
Uint8 propertyValueUint8;
val.get(propertyValueUint8);
value=WQLOperand(propertyValueUint8,WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_UINT16:
Uint16 propertyValueUint16;
val.get(propertyValueUint16);
value=WQLOperand(propertyValueUint16, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_UINT32:
Uint32 propertyValueUint32;
val.get(propertyValueUint32);
value=WQLOperand(propertyValueUint32, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_UINT64:
Uint64 propertyValueUint64;
val.get(propertyValueUint64);
value=WQLOperand(propertyValueUint64, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_SINT8:
Sint8 propertyValueSint8;
val.get(propertyValueSint8);
value=WQLOperand(propertyValueSint8, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_SINT16:
Sint16 propertyValueSint16;
val.get(propertyValueSint16);
value=WQLOperand(propertyValueSint16, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_SINT32:
Sint32 propertyValueSint32;
val.get(propertyValueSint32);
value=WQLOperand(propertyValueSint32, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_SINT64:
Sint64 propertyValueSint64;
val.get(propertyValueSint64);
value=WQLOperand(propertyValueSint64, WQL_INTEGER_VALUE_TAG);
break;
case CIMTYPE_REAL32:
Real32 propertyValueReal32;
val.get(propertyValueReal32);
value=WQLOperand(propertyValueReal32, WQL_DOUBLE_VALUE_TAG);
break;
case CIMTYPE_REAL64:
Real64 propertyValueReal64;
val.get(propertyValueReal64);
value=WQLOperand(propertyValueReal64, WQL_DOUBLE_VALUE_TAG);
break;
case CIMTYPE_BOOLEAN :
Boolean booleanValue;
val.get(booleanValue);
value=WQLOperand(booleanValue, WQL_BOOLEAN_VALUE_TAG);
break;
case CIMTYPE_CHAR16:
{
Char16 char16Value;
val.get(char16Value);
String str;
str.append(char16Value);
value=WQLOperand(str, WQL_STRING_VALUE_TAG);
break;
}
case CIMTYPE_DATETIME :
{
CIMDateTime datetimeValue;
val.get(datetimeValue);
//.........这里部分代码省略.........
示例11:
String::String(const CIMDateTime& parm) :
m_buf(NULL)
{
String s = parm.toString();
m_buf = s.m_buf;
}
示例12: if
void OSInfoCommand::gatherProperties(CIMInstance &inst, Boolean cimFormat)
{
// don't have a try here - want it to be caught by caller
// loop through the properties
for (Uint32 j=0; j < inst.getPropertyCount(); j++)
{
CIMName propertyName = inst.getProperty(j).getName();
// only pull out those properties of interest
if (propertyName.equal (CIMName ("CSName")))
{
inst.getProperty(j).getValue().get(osCSName);
} // end if CSName
else if (propertyName.equal (CIMName ("Name")))
{
inst.getProperty(j).getValue().get(osName);
} // end if Name
else if (propertyName.equal (CIMName ("NumberOfProcesses")))
{
Uint32 propertyValue;
inst.getProperty(j).getValue().get(propertyValue);
char tmpString[80];
sprintf(tmpString, "%d processes", propertyValue);
osNumberOfProcesses.assign(tmpString);
} // end if NumberOfProcesses
else if (propertyName.equal (CIMName ("NumberOfUsers")))
{
Uint32 propertyValue;
inst.getProperty(j).getValue().get(propertyValue);
char tmpString[80];
sprintf(tmpString, "%d users", propertyValue);
osNumberOfUsers.assign(tmpString);
} // end if NumberOfUsers
if (propertyName.equal (CIMName ("Version")))
{
inst.getProperty(j).getValue().get(osVersion);
} // end if Version
else if (propertyName.equal (CIMName ("OperatingSystemCapability")))
{
inst.getProperty(j).getValue().get(osCapability);
} // end if OSCapability
else if (propertyName.equal (CIMName ("OtherTypeDescription")))
{
inst.getProperty(j).getValue().get(osOtherInfo);
} // end if OtherTypeDescription
else if (propertyName.equal (CIMName ("NumberOfLicensedUsers")))
{
Uint32 propertyValue;
inst.getProperty(j).getValue().get(propertyValue);
// special consideration for HP-UX
if (propertyValue == 0)
{
if (String::equalNoCase(osVersion,"HP-UX"))
{
osLicensedUsers.assign("128, 256, or unlimited users");
}
else
{
osLicensedUsers.assign("Unlimited user license");
}
} // end if 0 as number of licensed users
else // standard number of users
{
char users[80];
sprintf(users, "%d users", propertyValue);
osLicensedUsers.assign(users);
}
} // end if NumberOfLicensedUsers
else if (propertyName.equal (CIMName ("LastBootUpTime")))
{
CIMDateTime bdate;
char bdateString[80];
inst.getProperty(j).getValue().get(bdate);
CString dtStr = bdate.toString().getCString();
if (!cimFormat)
{ // else leave in raw CIM
formatCIMDateTime(dtStr, bdateString);
}
else
{
sprintf(bdateString,"%s",(const char*)dtStr);
}
osBootUpTime.assign(bdateString);
} // end if LastBootUpTime
else if (propertyName.equal (CIMName ("LocalDateTime")))
{
CIMDateTime ldate;
char ldateString[80];
inst.getProperty(j).getValue().get(ldate);
//.........这里部分代码省略.........
示例13: PEG_METHOD_ENTER
String IndicationFormatter::_localizeDateTime(
const CIMDateTime & propertyValueDateTime,
const Locale & locale)
{
PEG_METHOD_ENTER (TRC_IND_FORMATTER,
"IndicationFormatter::_localizeDateTime");
// Convert dateTimeValue to be microSeconds,
// the number of microseconds from the epoch starting
// 0/0/0000 (12 am Jan 1, 1BCE)
//
CIMDateTime dateTimeValue = propertyValueDateTime;
Uint64 dateTimeValueInMicroSecs =
dateTimeValue.toMicroSeconds();
// In ICU, as UTC milliseconds from the epoch starting
// (1 January 1970 0:00 UTC)
CIMDateTime dt;
dt.set("19700101000000.000000+000");
// Convert dateTimeValue to be milliSeconds,
// the number of milliSeconds from the epoch starting
// (1 January 1970 0:00 UTC)
UDate dateTimeValueInMilliSecs =
(Sint64)(dateTimeValueInMicroSecs - dt.toMicroSeconds())/1000;
// Create a formatter for DATE and TIME with medium length
// such as Jan 12, 1952 3:30:32pm
DateFormat *fmt;
try
{
if (locale == 0)
{
fmt = DateFormat::createDateTimeInstance(DateFormat::MEDIUM,
DateFormat::MEDIUM);
}
else
{
fmt = DateFormat::createDateTimeInstance(DateFormat::MEDIUM,
DateFormat::MEDIUM,
locale);
}
}
catch(Exception& e)
{
PEG_TRACE_STRING(TRC_IND_FORMATTER, Tracer::LEVEL4, e.getMessage());
PEG_METHOD_EXIT();
return (dateTimeValue.toString());
}
catch(...)
{
PEG_TRACE_STRING(TRC_IND_FORMATTER, Tracer::LEVEL4,
"Caught General Exception During DateFormat::createDateTimeInstance");
PEG_METHOD_EXIT();
return (dateTimeValue.toString());
}
if (fmt == 0)
{
PEG_TRACE_STRING(TRC_IND_FORMATTER, Tracer::LEVEL4,
"Memory allocation error creating DateTime instance.");
PEG_METHOD_EXIT();
return (dateTimeValue.toString());
}
// Format the Date and Time
UErrorCode status = U_ZERO_ERROR;
UnicodeString dateTimeUniStr;
fmt->format(dateTimeValueInMilliSecs, dateTimeUniStr, status);
if (U_FAILURE(status))
{
delete fmt;
PEG_METHOD_EXIT();
return (dateTimeValue.toString());
}
// convert UnicodeString to char *
char dateTimeBuffer[256];
char *extractedStr = 0;
// Copy the contents of the string into dateTimeBuffer
Uint32 strLen = dateTimeUniStr.extract(0, sizeof(dateTimeBuffer),
dateTimeBuffer);
// There is not enough space in dateTimeBuffer
if (strLen > sizeof(dateTimeBuffer))
{
extractedStr = new char[strLen + 1];
strLen = dateTimeUniStr.extract(0, strLen + 1, extractedStr);
}
else
{
extractedStr = dateTimeBuffer;
}
//.........这里部分代码省略.........
示例14: testGetInstanceElement2
// Tests PROPERTY.ARRAY as an embedded object with array type.
static void testGetInstanceElement2(const char* testDataFile)
{
CIMInstance cimInstance;
Buffer text;
FileSystem::loadFileToMemory(text, testDataFile);
XmlParser parser((char*)text.getData());
XmlReader::getInstanceElement(parser, cimInstance);
PEGASUS_TEST_ASSERT(cimInstance.getClassName() ==
CIMName("CIM_InstCreation"));
Uint32 idx;
CIMProperty cimProperty;
CIMValue cimValue;
CIMType cimType;
PEGASUS_TEST_ASSERT(cimInstance.getPropertyCount() == 3);
idx = cimInstance.findProperty(CIMName("IndicationIdentifier"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "string") == 0);
String myString;
cimValue.get(myString);
PEGASUS_TEST_ASSERT(strcmp(myString.getCString(), "0") == 0);
idx = cimInstance.findProperty(CIMName("IndicationTime"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "datetime") == 0);
CIMDateTime myDateTime;
cimValue.get(myDateTime);
PEGASUS_TEST_ASSERT(myDateTime.equal(
CIMDateTime("20050227225624.524000-300")));
idx = cimInstance.findProperty(CIMName("SourceInstance"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "object") == 0);
Array<CIMObject> cimObject;
cimValue.get(cimObject);
PEGASUS_TEST_ASSERT(cimObject.size() == 2);
for (idx = 0; idx < cimObject.size(); idx++)
{
CIMInstance cimInstanceElement(cimObject[idx]);
PEGASUS_TEST_ASSERT(cimInstanceElement.getPropertyCount() == 2);
Uint32 propIdx = cimInstanceElement.findProperty(CIMName("uniqueId"));
if (propIdx != PEG_NOT_FOUND)
{
CIMProperty nestedProperty =
cimInstanceElement.getProperty(propIdx);
cimValue = nestedProperty.getValue();
Uint32 uniqueId;
cimValue.get(uniqueId);
propIdx = cimInstanceElement.findProperty(CIMName("lastOp"));
nestedProperty = cimInstanceElement.getProperty(propIdx);
cimValue = nestedProperty.getValue();
String checkStringValue;
cimValue.get(checkStringValue);
if (uniqueId == 1)
{
PEGASUS_TEST_ASSERT(strcmp(
checkStringValue.getCString(), "createInstance") == 0);
}
else if (uniqueId == 2)
{
PEGASUS_TEST_ASSERT(strcmp(
checkStringValue.getCString(), "deleteInstance") == 0);
}
else
{
PEGASUS_TEST_ASSERT(false);
}
}
}
}
示例15: testGetInstanceElement
// Tests PROPERTY as an embedded object.
static void testGetInstanceElement(const char* testDataFile)
{
//--------------------------------------------------------------------------
// Read in instance
//--------------------------------------------------------------------------
CIMInstance cimInstance;
Buffer text;
FileSystem::loadFileToMemory(text, testDataFile);
XmlParser parser((char*)text.getData());
XmlReader::getInstanceElement(parser, cimInstance);
PEGASUS_TEST_ASSERT(
cimInstance.getClassName() == CIMName("CIM_InstCreation"));
Uint32 idx;
CIMProperty cimProperty;
CIMValue cimValue;
CIMType cimType;
PEGASUS_TEST_ASSERT(cimInstance.getPropertyCount() == 3);
idx = cimInstance.findProperty(CIMName("IndicationIdentifier"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "string") == 0);
String myString;
cimValue.get(myString);
PEGASUS_TEST_ASSERT(strcmp(myString.getCString(), "0") == 0);
idx = cimInstance.findProperty(CIMName("IndicationTime"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "datetime") == 0);
CIMDateTime myDateTime;
cimValue.get(myDateTime);
PEGASUS_TEST_ASSERT(myDateTime.equal(
CIMDateTime("20050227225624.524000-300")));
idx = cimInstance.findProperty(CIMName("SourceInstance"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "object") == 0);
CIMObject cimObject;
cimValue.get(cimObject);
PEGASUS_TEST_ASSERT(
cimObject.getClassName() ==
CIMName("Sample_LifecycleIndicationProviderClass"));
PEGASUS_TEST_ASSERT(cimObject.getPropertyCount() == 2);
idx = cimObject.findProperty(CIMName("uniqueId"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimObject.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "uint32") == 0);
Uint32 myUint32;
cimValue.get(myUint32);
PEGASUS_TEST_ASSERT(myUint32 == 1);
idx = cimObject.findProperty(CIMName("lastOp"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimObject.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "string") == 0);
cimValue.get(myString);
PEGASUS_TEST_ASSERT(strcmp(myString.getCString(), "createInstance") == 0);
}