当前位置: 首页>>代码示例>>C++>>正文


C++ CIMDateTime::toString方法代码示例

本文整理汇总了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;
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:29,代码来源:OperatingSystem_Windows.cpp

示例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 &ltime,
    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);
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:35,代码来源:OSTestClient_Solaris.cpp

示例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
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:13,代码来源:OSTestClient_Solaris.cpp

示例4: goodLocalDateTime

Boolean OSTestClient::goodLocalDateTime(const CIMDateTime &ltime,
                                        Boolean verbose)
{
   if (verbose)
      cout<<"Checking LocalDateTime " << ltime.toString() << endl;
   cout<<"- No check written for LocalDateTime " << endl;
   return true;
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:8,代码来源:OSTestClient_VMS.cpp

示例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;
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:14,代码来源:OSTestClient_VMS.cpp

示例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);
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:26,代码来源:OSTestClient_Solaris.cpp

示例7: Str

 Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
开发者ID:deleisha,项目名称:neopegasus,代码行数:1,代码来源:EnumerationContext.cpp

示例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;
 }
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:WQLInstancePropertySource.cpp

示例9:

String::String(const CIMDateTime& parm) :
	m_buf(NULL)
{
	String s = parm.toString();
	m_buf = s.m_buf;
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:6,代码来源:OW_String.cpp

示例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);
//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:OSInfo.cpp

示例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;
    }

//.........这里部分代码省略.........
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:IndicationFormatter.cpp


注:本文中的CIMDateTime::toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。