本文整理汇总了C++中poco::DateTime类的典型用法代码示例。如果您正苦于以下问题:C++ DateTime类的具体用法?C++ DateTime怎么用?C++ DateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toStr
string HRCReport::toStr(const Poco::DateTime& date) const{
std::ostringstream ostr;
string sDate;
ostr << date.day() << "/" << date.month() << "/" << date.year();
sDate = ostr.str();
return sDate;
}
示例2: PopulateIDList
void InactiveIdentityRequester::PopulateIDList()
{
Poco::DateTime weekago;
int id;
int count=0;
SQLite3DB::Transaction trans(m_db);
weekago-=Poco::Timespan(7,0,0,0,0);
weekago.assign(weekago.year(),weekago.month(),weekago.day(),0,0,0);
// only selects, deferred OK
trans.Begin();
// select identities we want to query (haven't seen yet today) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)
SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen IS NOT NULL AND LastSeen<? AND tblIdentity.FailureCount<=(SELECT OptionValue FROM tblOption WHERE Option='MaxFailureCount') AND (PurgeDate IS NULL OR PurgeDate>datetime('now')) ORDER BY RANDOM();");
st.Bind(0, Poco::DateTimeFormatter::format(weekago,"%Y-%m-%d %H:%M:%S"));
trans.Step(st);
m_ids.clear();
while(st.RowReturned())
{
st.ResultInt(0,id);
m_ids[std::pair<long,long>(count,id)].m_requested=false;
trans.Step(st);
count+=1;
}
trans.Finalize(st);
trans.Commit();
}
示例3: startElement
void ForecastParser::startElement(const Poco::XML::XMLString& namespaceURI, const Poco::XML::XMLString& localName, const Poco::XML::XMLString& qname,
const Poco::XML::Attributes& attributes) {
static std::map <int, int> hmap = hourMap();
if (localName == "time"){
int tz = 0;
data.dateStr = attributes.getValue("", "from");
std::cout << data.dateStr << std::endl;
Poco::DateTime dt;
Poco::DateTimeParser::parse(data.dateStr, dt, tz);
data.date = Poco::DateTime(
dt.year(),
dt.month(),
dt.day(),
hmap[dt.hour()]
);
}
if (localName == "temperature"){
data.temperature = Poco::NumberParser::parse(attributes.getValue("", "value"));
}
if (localName == "symbol"){
data.img = Poco::NumberParser::parse(attributes.getValue("", "number"));
data.info = attributes.getValue("", "name");
}
if (localName == "windSpeed"){
data.wind = Poco::NumberParser::parseFloat(attributes.getValue("", "mps"));
}
if (localName == "precipitation"){
data.precipitation = Poco::NumberParser::parseFloat(attributes.getValue("", "value"));
}
}
示例4: parseNew
void SyslogParser::parseNew(const std::string& msg, RemoteSyslogChannel::Severity severity, RemoteSyslogChannel::Facility fac, std::size_t& pos)
{
Poco::Message::Priority prio = convert(severity);
// rest of the unparsed header is:
// VERSION SP TIMESTAMP SP HOSTNAME SP APP-NAME SP PROCID SP MSGID
std::string versionStr(parseUntilSpace(msg, pos));
std::string timeStr(parseUntilSpace(msg, pos)); // can be the nilvalue!
std::string hostName(parseUntilSpace(msg, pos));
std::string appName(parseUntilSpace(msg, pos));
std::string procId(parseUntilSpace(msg, pos));
std::string msgId(parseUntilSpace(msg, pos));
std::string message(msg.substr(pos));
pos = msg.size();
Poco::DateTime date;
int tzd = 0;
bool hasDate = Poco::DateTimeParser::tryParse(RemoteSyslogChannel::SYSLOG_TIMEFORMAT, timeStr, date, tzd);
Poco::Message logEntry(msgId, message, prio);
logEntry["host"] = hostName;
logEntry["app"] = appName;
if (hasDate)
logEntry.setTime(date.timestamp());
int lval(0);
Poco::NumberParser::tryParse(procId, lval);
logEntry.setPid(lval);
_pListener->log(logEntry);
}
示例5: testInsertRequest
void MongoDBTest::testInsertRequest()
{
if (!_connected)
{
std::cout << "Not connected, test skipped." << std::endl;
return;
}
Poco::MongoDB::Document::Ptr player = new Poco::MongoDB::Document();
player->add("lastname", std::string("Braem"));
player->add("firstname", std::string("Franky"));
Poco::DateTime birthdate;
birthdate.assign(1969, 3, 9);
player->add("birthdate", birthdate.timestamp());
player->add("start", 1993);
player->add("active", false);
Poco::DateTime now;
std::cout << now.day() << " " << now.hour() << ":" << now.minute() << ":" << now.second() << std::endl;
player->add("lastupdated", now.timestamp());
player->add("unknown", NullValue());
Poco::MongoDB::InsertRequest request("team.players");
request.documents().push_back(player);
_mongo.sendRequest(request);
}
示例6: run
void run()
{
for(int i=0; i<kNumEnqueueByChild; ++i)
{
int counter = ++m_counter;
Poco::DateTime datetime;
datetime += Poco::Timespan(m_rnd.next(kScheduleMaxTime)*1000);
m_queue.enqueueNotification(new ChildNotification(counter, m_name, datetime), datetime.timestamp());
datetime.makeLocal(Poco::Timezone::tzd());
m_msg.Message(Poco::format(" enqueueNotification #%d from %s (%s)"
, counter
, m_name
, Poco::DateTimeFormatter::format(datetime.timestamp(), "%H:%M:%S.%i")));
}
}
示例7: main
int main()
{
Poco::DateTime now;
char szClientName[256] = { 0, };
sprintf_s(szClientName, 256 - 1, "(%d-%d)", now.second(), now.millisecond());
std::cout << "clinet(" << szClientName << ") 서버에 연결 시도..." << std::endl;
Poco::Net::StreamSocket ss;
try
{
ss.connect(Poco::Net::SocketAddress("localhost", PORT));
for (int i = 0; i < 7; ++i)
{
char szMessage[256] = { 0, };
sprintf_s(szMessage, 256 - 1, "%d, Send Message From %s", i, szClientName);
auto nMsgLen = (int)strnlen_s(szMessage, 256 - 1);
ss.sendBytes(szMessage, nMsgLen);
std::cout << "서버에 보낸 메시지: " << szMessage << std::endl;
char buffer[256] = { 0, };
auto len = ss.receiveBytes(buffer, sizeof(buffer));
if (len <= 0)
{
std::cout << "서버와 연결이 끊어졌습니다" << std::endl;
break;
}
std::cout << "서버로부터 받은 메시지: " << buffer << std::endl;
Poco::Thread::sleep(256);
}
ss.close();
}
catch (Poco::Exception& exc)
{
std::cout << "서버 접속 실패: " << exc.displayText() << std::endl;
}
getchar();
return 0;
}
示例8: Stop
void ClearHistory::Stop()
{
if (!_stopped) {
_rdbmsClearHis->stop();
_stopped = true;
Poco::DateTime dataTime;
dataTime += 10;
ClearQueue.enqueueNotification(new ClearNotofication(0 ),dataTime.timestamp());
_thread.join();
ClearQueue.clear();
g_pClearHistory = NULL;
}
}
示例9: dump
void TextSerializer::dump()
{
if (buffer.size() == 0)
return;
Poco::DateTime date = buffer[0]->DateTime;
string file = Poco::format("%s/%04d%02d%02d.csv", path, date.year(), date.month(), date.day());
std::ofstream os;
os.open (file, std::ofstream::out | std::ofstream::app);
for (int i = 0; i < buffer.size(); i++)
os << serTick(buffer[i]);
os << std::flush;
os.close();
}
示例10: main
//----------------------------------------
// main
//----------------------------------------
int main(int /*argc*/, char** /*argv*/)
{
PrepareConsoleLogger logger(Poco::Logger::ROOT, Poco::Message::PRIO_INFORMATION);
ScopedLogMessage msg("DateTimeTest ", "start", "end");
Poco::DateTime dateTime;
msg.Message(" Current DateTime (UTC)");
DisplayDateTime(dateTime, msg);
msg.Message(Poco::format(" Current DateTime (Locat Time: %s [GMT%+d])", Poco::Timezone::name(), Poco::Timezone::tzd()/(60*60)));
dateTime.makeLocal(Poco::Timezone::tzd());
DisplayDateTime(dateTime, msg);
msg.Message(Poco::format(Poco::DateTimeFormatter::format(dateTime, " DateTimeFormatter: %w %b %e %H:%M:%S %%s %Y")
, Poco::Timezone::name()));
return 0;
}
示例11: CheckForNeededInsert
void TrustListInserter::CheckForNeededInsert()
{
Poco::DateTime date;
int currentday=date.day();
date-=Poco::Timespan(0,6,0,0,0);
// insert trust lists every 6 hours - if 6 hours ago was different day then set to midnight of current day to insert list today ASAP
if(currentday!=date.day())
{
date.assign(date.year(),date.month(),currentday,0,0,0);
}
SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID, PrivateKey FROM tblLocalIdentity WHERE tblLocalIdentity.Active='true' AND PrivateKey IS NOT NULL AND PrivateKey <> '' AND PublishTrustList='true' AND InsertingTrustList='false' AND (LastInsertedTrustList<=? OR LastInsertedTrustList IS NULL);");
st.Bind(0,Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S"));
st.Step();
if(st.RowReturned())
{
int lid=0;
std::string pkey("");
st.ResultInt(0,lid);
st.ResultText(1,pkey);
StartInsert(lid,pkey);
}
}
示例12: GenTick
CThostFtdcDepthMarketDataField* Exchange::GenTick()
{
Poco::DateTime now;
string date = Poco::format("%02d%02d%02d", now.year(), now.month(), now.day());
string time = Poco::format("%02d:%02d:%02d", now.hour(), now.minute(), now.second());
strcpy(tick->TradingDay, date.c_str());
strcpy(tick->UpdateTime, time.c_str());
strcpy(tick->InstrumentID, INSTRUMENT);
tick->UpdateMillisec = now.millisecond();
tick->LastPrice = RandomWalk(tick->LastPrice);
tick->Volume = tick->Volume;
return tick;
}
示例13: prefix
char* prefix(char* buffer, const std::size_t len, const char* level)
{
const char *threadName = Util::getThreadName();
#ifdef __linux
const long osTid = Util::getThreadId();
#elif defined IOS
const auto osTid = pthread_mach_thread_np(pthread_self());
#endif
Poco::DateTime time;
snprintf(buffer, len, "%s-%.05lu %.4u-%.2u-%.2u %.2u:%.2u:%.2u.%.6u [ %s ] %s ",
(Source.getInited() ? Source.getId().c_str() : "<shutdown>"),
osTid,
time.year(), time.month(), time.day(),
time.hour(), time.minute(), time.second(),
time.millisecond() * 1000 + time.microsecond(),
threadName, level);
return buffer;
}
示例14: CheckForNeededInsert
void IntroductionPuzzleInserter::CheckForNeededInsert()
{
// only do 1 insert at a time
if(m_inserting.size()==0)
{
// select all local ids that aren't single use and that aren't currently inserting a puzzle and are publishing a trust list
SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID FROM tblLocalIdentity WHERE tblLocalIdentity.Active='true' AND PublishTrustList='true' AND SingleUse='false' AND PrivateKey IS NOT NULL AND PrivateKey <> '' ORDER BY LastInsertedPuzzle;");
st.Step();
// FIXME Convert to nested SELECT
SQLite3DB::Statement st2=m_db->Prepare("SELECT UUID FROM tblIntroductionPuzzleInserts WHERE Day=? AND FoundSolution='false' AND LocalIdentityID=?;");
while(st.RowReturned())
{
int localidentityid=0;
std::string localidentityidstr="";
Poco::DateTime now;
float minutesbetweeninserts=0;
minutesbetweeninserts=1440.0/(float)m_maxpuzzleinserts;
Poco::DateTime lastinsert=now;
lastinsert-=Poco::Timespan(0,0,minutesbetweeninserts,0,0);
st.ResultInt(0, localidentityid);
StringFunctions::Convert(localidentityid, localidentityidstr);
// if this identity has any non-solved puzzles for today, we don't need to insert a new puzzle
st2.Bind(0, Poco::DateTimeFormatter::format(now,"%Y-%m-%d"));
st2.Bind(1, localidentityid);
st2.Step();
// identity doesn't have any non-solved puzzles for today - start a new insert
if(!st2.RowReturned())
{
// make sure we are on the next day or the appropriate amount of time has elapsed since the last insert
std::map<int,Poco::DateTime>::iterator i;
if((i=m_lastinserted.find(localidentityid))==m_lastinserted.end() || (*i).second<=lastinsert || (*i).second.day()!=now.day())
{
StartInsert(localidentityid);
m_lastinserted[localidentityid]=now;
}
else
{
m_log->trace("IntroductionPuzzleInserter::CheckForNeededInsert waiting to insert puzzle for "+localidentityidstr);
}
} else {
st2.Reset();
}
st.Step();
}
}
}
示例15: testInsertRequest
void MongoDBTest::testInsertRequest()
{
Poco::MongoDB::Document::Ptr player = new Poco::MongoDB::Document();
player->add("lastname", std::string("Braem"));
player->add("firstname", std::string("Franky"));
Poco::DateTime birthdate;
birthdate.assign(1969, 3, 9);
player->add("birthdate", birthdate.timestamp());
player->add("start", 1993);
player->add("active", false);
Poco::DateTime now;
player->add("lastupdated", now.timestamp());
player->add("unknown", NullValue());
Poco::MongoDB::InsertRequest request("team.players");
request.documents().push_back(player);
_mongo->sendRequest(request);
}