本文整理汇总了C++中boost::posix_time::ptime::time_of_day方法的典型用法代码示例。如果您正苦于以下问题:C++ ptime::time_of_day方法的具体用法?C++ ptime::time_of_day怎么用?C++ ptime::time_of_day使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::posix_time::ptime
的用法示例。
在下文中一共展示了ptime::time_of_day方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: af_timestamp
string AutoFlight::af_timestamp()
{
const boost::posix_time::ptime time = boost::posix_time::second_clock::local_time();
stringstream timestamp;
timestamp << setw(4) << setfill('0') << time.date().year() << setw(2) << time.date().month().as_number() << setw(2) << time.date().day().as_number();
timestamp << "T";
timestamp << setw(2) << time.time_of_day().hours() << setw(2) << time.time_of_day().minutes() << setw(2) << time.time_of_day().seconds();
return timestamp.str();
}
示例2:
void BindArgDataHolder::ArgSetter::operator()( MYSQL_BIND &arg, const boost::posix_time::ptime &datetime )
{
MYSQL_TIME *ts = reinterpret_cast<MYSQL_TIME *>( arg.buffer );
ts->year = datetime.date().year();
ts->month = datetime.date().month();
ts->day = datetime.date().day();
ts->hour = datetime.time_of_day().hours();
ts->minute = datetime.time_of_day().minutes();
ts->second = datetime.time_of_day().seconds();
}
示例3: toString
std::string TimeConversion::toString(const boost::posix_time::ptime ts, const int secPrecision) const
{
using namespace boost::posix_time;
// determine the nanoseconds given in ts
const int h = ts.time_of_day().hours();
const int m = ts.time_of_day().minutes();
const int s = ts.time_of_day().seconds();
const time_duration r = time_duration(h, m, s);
const time_duration rest = ts.time_of_day() - r;
const int nanoseconds = int(rest.total_nanoseconds()); // not more than 1 bil nanoseconds here.
return toString(to_tm(ts), nanoseconds, secPrecision);
}
示例4:
inline boost::uint64_t hash_value(const boost::posix_time::ptime& value, boost::uint64_t seed)
{
seed = hash_value(value.date(), seed);
seed = hash_value(value.time_of_day(), seed);
return seed;
}
示例5: ValToBuf
int CH104_Transmit::AssembleSynTime(size_t bufIndex, unsigned char * buf, stSynTimePara para,boost::posix_time::ptime time)
{
size_t count = bufIndex;
buf[count++] = 0x68;
count += ValToBuf(&buf[count],0,FrameLenLength_);
count += ValToBuf(&buf[count],para.IFrameSendCounter_,2);
count += ValToBuf(&buf[count],para.IFrameRecvCounter_,2);
count += ValToBuf(&buf[count],M_CS_NA_1,FrameTypeLength_);
count += ValToBuf(&buf[count],0x01,InfoNumLength_);
count += ValToBuf(&buf[count],trans_act,TransReasonLength_);
count += ValToBuf(&buf[count],para.addr_,AsduAddrLength_);
count += ValToBuf(&buf[count],0,InfoAddrLength_);
boost::posix_time::time_duration td = time.time_of_day();
count += ValToBuf(&buf[count],td.total_milliseconds() % MinutesRemainderMillisecs,2);
buf[count++] = td.minutes() & 0x3f;
buf[count++] = td.hours() & 0x1f;
boost::gregorian::date::ymd_type ymd = time.date().year_month_day();
//buf[count++] = ymd.day & 0x1f;
buf[count++] = ((time.date().day_of_week()<<5) & 0xe0) | (ymd.day & 0x1f);
buf[count++] = ymd.month & 0x0f;
buf[count++] = ymd.year % 100;
int len = count - bufIndex - (FrameLenLength_ + SYN_HEAD_LENGTH);
ValToBuf(&buf[FrameLenLocation_],len,FrameLenLength_);
return count - bufIndex;
}
示例6: pttoqt
QDateTime pttoqt(const boost::posix_time::ptime &pt) {
boost::gregorian::date gd = pt.date();
boost::posix_time::time_duration gt = pt.time_of_day();
QDate qdate(gd.year(), gd.month(), gd.day());
QTime qtime(gt.hours(), gt.minutes(), gt.seconds());
return QDateTime(qdate, qtime);
}
示例7: rotate_stores
void rotate_stores()
{
std::cout << "Rotating store " << store_file << "..." << std::endl;
std::cout << "Rotating store call flush " << store_file << "..." << std::endl;
fflush(stdout);
try {
store->flush(true);
} catch (klio::StoreException const& ex) {
std::cout << "Failed to flush the buffers : " << ex.what() << std::endl;
}
std::cout << "Rotating store flushed " << store_file << "..." << std::endl;
fflush(stdout);
std::cout << "Reopening store" << std::endl;
const boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
std::string s;
s= str( format("%04d%02d%02d-%02d%02d") % now.date().year_month_day().year
% now.date().year_month_day().month.as_number()
% now.date().year_month_day().day.as_number()
% now.time_of_day().hours()
% now.time_of_day().minutes());
std::string name(store_file.string());
name+=".";
name+=s;
bfs::path dbname(name);
std::cout << "===> renaming to: "<< name<<std::endl;
fflush(stdout);
try {
store->rotate(dbname);
} catch (klio::StoreException const& ex) {
std::cout << "Failed to rotate the klio-databse : " << ex.what() << std::endl;
}
#if KLIO_AUTOCOMMIT
store->start_transaction();
#endif
std::cout << "Rotation done" << std::endl;
}
示例8: to_tm
//! Convert a time to a tm structure truncating any fractional seconds
inline
std::tm to_tm(const boost::posix_time::ptime& t) {
std::tm timetm = boost::gregorian::to_tm(t.date());
boost::posix_time::time_duration td = t.time_of_day();
timetm.tm_hour = td.hours();
timetm.tm_min = td.minutes();
timetm.tm_sec = td.seconds();
timetm.tm_isdst = -1; // -1 used when dst info is unknown
return timetm;
}
示例9: to_tm
//! Convert a time to a tm structure truncating any fractional seconds
inline
tm to_tm(const boost::posix_time::ptime& t) {
tm timetm = boost::gregorian::to_tm(t.date());
boost::posix_time::time_duration td = t.time_of_day();
timetm.tm_hour = td.hours();
timetm.tm_min = td.minutes();
timetm.tm_sec = td.seconds();
timetm.tm_isdst = -1; //?
return timetm;
}
示例10: FromBoostPtime
static void FromBoostPtime(const boost::posix_time::ptime& pt, Time& t)
{
boost::gregorian::date d = pt.date();
t.m_year = d.year();
t.m_month = d.month();
t.m_day = d.day();
boost::posix_time::time_duration tod = pt.time_of_day();
t.m_hour = tod.hours();
t.m_minute = tod.minutes();
t.m_second = tod.seconds();
t.m_fraction_of_second = tod.fractional_seconds() / pow(10.0, tod.num_fractional_digits());
}
示例11:
std::pair< comma::uint32, comma::uint32 > to_ntp_time( boost::posix_time::ptime t )
{
if( t < ntp_base ) { COMMA_THROW_STREAM( comma::exception, "cannot convert to ntp time: " << t << ", which is less than NTP time base " << ntp_base ); }
comma::int32 s = ( t - epoch_time ).total_seconds(); // 32 bit signed int in boost and posix
comma::int32 m = t.time_of_day().total_microseconds() % 1000000;
if( t >= epoch_time || m == 0 )
{
return std::pair< comma::uint32, comma::uint32 >( static_cast< comma::uint32 >( ntp_diff + s ), static_cast< comma::uint32 >( m / ntp_microsec_coeff ) );
}
else
{
return std::pair< comma::uint32, comma::uint32 >( static_cast< comma::uint32 >( ntp_diff + s - 1 ), static_cast< comma::uint32 >( m / ntp_microsec_coeff ) );
}
}
示例12: append_timestamp
void append_timestamp(Stream& stream, boost::posix_time::ptime timestamp)
{
auto date = timestamp.date();
auto time = timestamp.time_of_day();
auto milliseconds = time.fractional_seconds() / 1000; // microseconds to milliseconds
std::wstringstream buffer;
buffer << std::setfill(L'0') << L"[" << std::setw(4) << date.year() << L"-" << std::setw(2)
<< date.month().as_number() << "-" << std::setw(2) << date.day().as_number() << L" " << std::setw(2)
<< time.hours() << L":" << std::setw(2) << time.minutes() << L":" << std::setw(2) << time.seconds() << L"."
<< std::setw(3) << milliseconds << L"] ";
stream << buffer.str();
}
示例13: operator
NonOptionalValuePrettyPrint::result_type NonOptionalValuePrettyPrint::operator()(const boost::posix_time::ptime &value) const
{
return boost::gregorian::to_iso_extended_string(value.date()) + std::string(" ") + boost::posix_time::to_simple_string(value.time_of_day());
}
示例14: Truncate
/*!
\param time The time point to truncate.
\param unit The unit of time to truncate the time point to.
\return The time point truncated to the specified <i>unit</i>.
*/
inline boost::posix_time::ptime Truncate(const boost::posix_time::ptime& time,
boost::posix_time::time_duration unit) {
return time - boost::posix_time::microseconds(
time.time_of_day().total_microseconds() % unit.total_microseconds());
}
示例15: write
void write(string const&logLev, string info, boost::posix_time::ptime time)
{
int year = time.date().year();
int month = time.date().month();
int day = time.date().day();
std::string time_str = boost::str(boost::format("%d-%02d-%02d")%year%month%day);
boost::gregorian::date local_day = boost::gregorian::day_clock::local_day();
std::string log_date_time = boost::gregorian::to_iso_extended_string(local_day);
if(!time.time_of_day().is_special()) {
char sep = ' ';
time_str += sep + boost::posix_time::to_simple_string(time.time_of_day());
}
if (elog_factory::instance().get_root_path().empty())
{
return;
}
std::string destfileUtf = epfilesystem::instance().sub_path(elog_factory::instance().get_root_path(), "log");
std::string fileName = log_date_time + "-" + file_name_;
destfileUtf = epfilesystem::instance().sub_path(destfileUtf, fileName);
#ifdef _WIN32
std::wstring destfile = UTF2WS(destfileUtf);
#else
std::string destfile = destfileUtf;
#endif
if(!ofs_)
{
#ifdef _WIN32
ofs_.reset(new ofstream(destfile.c_str(), (append_mode_?ios::app:0) | ios::binary ));
#else
if(append_mode_)
{
ofs_.reset(new std::ofstream(destfile.c_str(),ios::app | ios::binary));
}
else
{
ofs_.reset(new std::ofstream(destfile.c_str(),ios::binary));
}
#endif
}
// 客户端 IM-2941 密码明文显示的修改
std::wstring bingo = L"\"user_passwd\":\"";
std::wstring winfo = txtutil::convert_utf8_to_wcs(info);
std::wstring::size_type index = std::wstring::npos;
std::wstring::size_type eindex= std::wstring::npos;
index = winfo.find(bingo);
do{
if (index != std::wstring::npos)
{
eindex = winfo.find(L'\"', index + bingo.length());
if (eindex != std::wstring::npos)
{
winfo.erase(index + bingo.length(), eindex-index-bingo.length());
}
index = winfo.find(bingo, eindex);
}
}while(index != std::wstring::npos);
info = txtutil::convert_wcs_to_utf8(winfo);
std::string version_num = elog_factory::instance().get_version_num();
if (version_num !="")
{
*ofs_ << "[" + time_str +"-"+ version_num +"]" + logLev << ":\t"<<info << endl;
}
else
{
*ofs_ << "[" + time_str + "]" + logLev << ":\t"<<info << endl;
}
ofs_.reset();
}