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


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

本文整理汇总了C++中CIMDateTime::toMicroSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMDateTime::toMicroSeconds方法的具体用法?C++ CIMDateTime::toMicroSeconds怎么用?C++ CIMDateTime::toMicroSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIMDateTime的用法示例。


在下文中一共展示了CIMDateTime::toMicroSeconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:9,代码来源:WsmUtils.cpp

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