本文整理汇总了C++中TimeZone::milspec方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeZone::milspec方法的具体用法?C++ TimeZone::milspec怎么用?C++ TimeZone::milspec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeZone
的用法示例。
在下文中一共展示了TimeZone::milspec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: milspec
const char* TimeStamp::milspec(const LocalTime& lt) {
TimeZone zone;
::snprintf(this->buffer, sizeof(this->buffer),
"%04llu-%3.3s-%02u %02u:%02u:%02u%1.1s",
lt.getYear(), lt.getDate().monthToString(), lt.getDay(),
lt.getHour(), lt.getMinute(), lt.getSecond(),
zone.milspec(lt.getOffset()));
this->buffer[sizeof(this->buffer) - 1] = '\0';
assert(std::strlen(this->buffer) < sizeof(this->buffer));
return this->buffer;
}
示例2: log
// Log line space is at a premium. It pays to have as high a precision timestamp
// as the underlying platform supports, but no more. Generally about a
// microsecond is the best we can hope for on Linux platforms. But I've used
// vxWorks platforms that had time bases accurate to tens of nanoseconds. So
// consider altering the print format from ".%06u" to ".%09u" and removing the
// "/ 1000" nanosecond divisor.
const char* TimeStamp::log(const LocalTime& lt) {
TimeZone zone;
::snprintf(this->buffer, sizeof(this->buffer),
"%04llu-%02u-%02u %02u:%02u:%02u.%06u%1.1s",
lt.getYear(), lt.getMonth(), lt.getDay(),
lt.getHour(), lt.getMinute(), lt.getSecond(),
lt.getNanosecond() / 1000,
zone.milspec(lt.getOffset()));
this->buffer[sizeof(this->buffer) - 1] = '\0';
assert(std::strlen(this->buffer) < sizeof(this->buffer));
return this->buffer;
}