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


C++ Date_t::asInt64方法代码示例

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


在下文中一共展示了Date_t::asInt64方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setNow

 void NetworkInterfaceMock::setNow(Date_t newNow) {
     boost::lock_guard<boost::mutex> lk(_mutex);
     invariant(newNow.asInt64() > _now.asInt64());
     _now = newNow;
     _executor->signalWorkForTest();
     _timeElapsed.notify_all();
 }
开发者ID:DieterLutz,项目名称:mongo,代码行数:7,代码来源:network_interface_mock.cpp

示例2: dateToCtimeString

    std::string dateToCtimeString(Date_t date) {
        time_t t = date.toTimeT();
        char buf[64];
#if defined(_WIN32)
        ctime_s(buf, sizeof(buf), &t);
#else
        ctime_r(&t, buf);
#endif
        char* milliSecStr = buf + 19;
        snprintf(milliSecStr, 5, ".%03d", static_cast<int32_t>(date.asInt64() % 1000));
        return buf;
    }
开发者ID:504com,项目名称:mongo,代码行数:12,代码来源:time_support.cpp

示例3: strftime

    static inline std::string _dateToISOString(Date_t date, bool local) {
        const int bufSize = 32;
        char buf[bufSize];
        struct tm t;
        time_t_to_Struct(date.toTimeT(), &t, local);
        int pos = strftime(buf, bufSize, MONGO_ISO_DATE_FMT_NO_TZ, &t);
        fassert(16981, 0 < pos);
        char* cur = buf + pos;
        int bufRemaining = bufSize - pos;
        pos = snprintf(cur, bufRemaining, ".%03d", static_cast<int32_t>(date.asInt64() % 1000));
        fassert(16982, bufRemaining > pos && pos > 0);
        cur += pos;
        bufRemaining -= pos;
        if (local) {
            fassert(16983, bufRemaining >= 6);
#ifdef _WIN32
            // NOTE(schwerin): The value stored by _get_timezone is the value one adds to local time
            // to get UTC.  This is opposite of the ISO-8601 meaning of the timezone offset.
            // NOTE(schwerin): Microsoft's timezone code always assumes US rules for daylight
            // savings time.  We can do no better without completely reimplementing localtime_s and
            // related time library functions.
            long msTimeZone;
            _get_timezone(&msTimeZone);
            if (t.tm_isdst) msTimeZone -= 3600;
            const bool tzIsWestOfUTC = msTimeZone > 0;
            const long tzOffsetSeconds = msTimeZone* (tzIsWestOfUTC ? 1 : -1);
            const long tzOffsetHoursPart = tzOffsetSeconds / 3600;
            const long tzOffsetMinutesPart = (tzOffsetSeconds / 60) % 60;
            snprintf(cur, 6, "%c%02ld%02ld",
                     tzIsWestOfUTC ? '-' : '+',
                     tzOffsetHoursPart,
                     tzOffsetMinutesPart);
#else
            strftime(cur, bufRemaining, "%z", &t);
#endif
        }
        else {
            fassert(16984, bufRemaining >= 2);
            *cur = 'Z';
            ++cur;
            *cur = '\0';
        }
        return buf;
    }
开发者ID:504com,项目名称:mongo,代码行数:44,代码来源:time_support.cpp


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