本文整理汇总了C++中CIMDateTime::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMDateTime::toString方法的具体用法?C++ CIMDateTime::toString怎么用?C++ CIMDateTime::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMDateTime
的用法示例。
在下文中一共展示了CIMDateTime::toString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLastBootUpTime
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: 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);
}
示例7: Str
Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
示例8: getValue
//.........这里部分代码省略.........
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);
value=WQLOperand(datetimeValue.toString(),WQL_STRING_VALUE_TAG);
break;
}
case CIMTYPE_STRING :
{
String strValue;
val.get(strValue);
value=WQLOperand(strValue,WQL_STRING_VALUE_TAG);
break;
}
default: return false;
}
return true;
}
示例9:
String::String(const CIMDateTime& parm) :
m_buf(NULL)
{
String s = parm.toString();
m_buf = s.m_buf;
}
示例10: gatherProperties
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);
//.........这里部分代码省略.........
示例11: _localizeDateTime
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;
}
//.........这里部分代码省略.........