本文整理汇总了C++中Date_t::toTimeT方法的典型用法代码示例。如果您正苦于以下问题:C++ Date_t::toTimeT方法的具体用法?C++ Date_t::toTimeT怎么用?C++ Date_t::toTimeT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date_t
的用法示例。
在下文中一共展示了Date_t::toTimeT方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: veto
void ReplSetImpl::veto(const string& host, const Date_t until) {
lock lk(this);
_veto[host] = until.toTimeT();
}