本文整理汇总了C++中DateTime::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::Format方法的具体用法?C++ DateTime::Format怎么用?C++ DateTime::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::Format方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WHERE
void DBMaintenance::Do1DayMaintenance()
{
DateTime yesterday;
DateTime tendaysago;
yesterday.Add(0,0,0,-1);
tendaysago.Add(0,0,0,-10);
m_db->Execute("BEGIN;");
SQLite3DB::Statement st=m_db->Prepare("DELETE FROM tblIdentity WHERE (DateAdded<? AND LastSeen IS NULL) OR LastSeen<? AND Ignored=0;");
st.Bind(0,tendaysago.Format("%Y-%m-%d"));
st.Bind(1,tendaysago.Format("%Y-%m-%d"));
st.Step();
st=m_db->Prepare("DELETE FROM tblAnnounceIndex WHERE Date<?;");
st.Bind(0,yesterday.Format("%Y-%m-%d"));
st.Step();
st=m_db->Prepare("DELETE FROM tblIdentityEdition WHERE Date<?;");
st.Bind(0,yesterday.Format("%Y-%m-%d"));
st.Step();
st=m_db->Prepare("DELETE FROM tblInsertedMessageIndex WHERE Date<?;");
st.Bind(0,yesterday.Format("%Y-%m-%d"));
st.Step();
st=m_db->Prepare("DELETE FROM tblRetrievedMessageIndex WHERE Date<?;");
st.Bind(0,yesterday.Format("%Y-%m-%d"));
st.Step();
m_db->Execute("COMMIT;");
m_log->Error("DBMaintenance::Do1DayMaintenance");
}
示例2: StartTopicInsert
void FreenetMessageInserter::StartTopicInsert(const int localidentityid, const std::string &channel, const std::string &topic)
{
SQLite3DB::Statement st;
std::string idstr("");
std::string data("");
std::string datalengthstr("");
DateTime now;
FCPv2::Message mess("ClientPut");
LoadLocalIdentityPrivateKey(localidentityid);
if(m_identitykeys[localidentityid]!="")
{
std::string indexstr("0");
FreenetMessage fm;
fm["type"]="settopic";
fm["channel"]=channel;
fm["sentdate"]=now.Format("%Y-%m-%d %H:%M:%S");
fm.Body()=topic;
data=fm.GetMessageText();
StringFunctions::Convert(localidentityid,idstr);
StringFunctions::Convert(data.size(),datalengthstr);
StringFunctions::Convert(GetNextMessageIndex(localidentityid,now),indexstr);
st=m_db->Prepare("INSERT INTO tblInsertedMessageIndex(LocalIdentityID,Date,MessageIndex) VALUES(?,?,?);");
st.Bind(0,localidentityid);
st.Bind(1,now.Format("%Y-%m-%d"));
st.Bind(2,indexstr);
st.Step();
mess["URI"]="[email protected]"+m_identitykeys[localidentityid].substr(4)+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Message-"+indexstr;
mess["Identifier"]=m_fcpuniqueidentifier+"|"+idstr+"|"+now.Format("%Y-%m-%d")+"|"+indexstr+"|"+mess["URI"];
mess["RealTimeFlag"]="true";
mess["UploadFrom"]="direct";
mess["PriorityClass"]=m_insertpriority;
mess["ExtraInsertsSingleBlock"]="0";
mess["DataLength"]=datalengthstr;
mess["Metadata.ContentType"]="";
m_fcp->Send(mess);
m_fcp->Send(std::vector<char>(data.begin(),data.end()));
m_log->Debug("FreenetMessageInserter::StartInsert started insert of channel topic "+mess["Identifier"]);
}
}
示例3: GetNextMessageIndex
const int FreenetMessageInserter::GetNextMessageIndex(const int localidentityid, const DateTime &date)
{
int index=0;
SQLite3DB::Statement st=m_db->Prepare("SELECT IFNULL(MAX(MessageIndex)+1,0) FROM tblInsertedMessageIndex WHERE LocalIdentityID=? AND Date=?;");
st.Bind(0,localidentityid);
st.Bind(1,date.Format("%Y-%m-%d"));
st.Step();
if(st.RowReturned())
{
st.ResultInt(0,index);
}
return index;
}
示例4: LogText
void LogFile::LogText(const CString& cszText, bool bLongDate)
{
if (m_spStream == NULL)
return;
DateTime dt = DateTime::Now();
CString cszTemp;
cszTemp.Format(_T("[%s] %s"),
dt.Format(bLongDate ? _T("%Y-%m-%d %H:%M:%S") : _T("%H:%M:%S")).GetString(),
cszText.GetString());
m_spStream->Write(cszTemp);
m_spStream->WriteEndline();
m_spStream->Flush();
}
示例5: StartPrivateInsert
void FreenetMessageInserter::StartPrivateInsert(const int localidentityid, const int recipientidentityid, const std::string &message)
{
RSAKeyPair rsa;
std::string idstr("");
std::string publickey("");
std::string rsapublickey("");
std::string data("");
std::string datalengthstr("");
DateTime now;
FCPv2::Message mess("ClientPut");
LoadLocalIdentityPrivateKey(localidentityid);
SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, RSAPublicKey FROM tblIdentity WHERE IdentityID=?;");
st.Bind(0,recipientidentityid);
st.Step();
if(st.RowReturned())
{
st.ResultText(0,publickey);
st.ResultText(1,rsapublickey);
}
if(publickey!="" && rsapublickey!="" && rsa.SetFromEncodedPublicKey(rsapublickey))
{
if(m_identitykeys[localidentityid]!="")
{
std::string indexstr("0");
FreenetMessage fm;
fm["type"]="privatemessage";
fm["recipient"]=publickey;
fm["sentdate"]=now.Format("%Y-%m-%d %H:%M:%S");
rsa.Encrypt(message,fm.Body());
data=fm.GetMessageText();
StringFunctions::Convert(localidentityid,idstr);
StringFunctions::Convert(data.size(),datalengthstr);
StringFunctions::Convert(GetNextMessageIndex(localidentityid,now),indexstr);
st=m_db->Prepare("INSERT INTO tblInsertedMessageIndex(LocalIdentityID,Date,MessageIndex) VALUES(?,?,?);");
st.Bind(0,localidentityid);
st.Bind(1,now.Format("%Y-%m-%d"));
st.Bind(2,indexstr);
st.Step();
mess["URI"]="[email protected]"+m_identitykeys[localidentityid].substr(4)+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Message-"+indexstr;
mess["Identifier"]=m_fcpuniqueidentifier+"|"+idstr+"|"+now.Format("%Y-%m-%d")+"|"+indexstr+"|"+mess["URI"];
mess["RealTimeFlag"]="true";
mess["UploadFrom"]="direct";
mess["PriorityClass"]=m_insertpriority;
mess["ExtraInsertsSingleBlock"]="0";
mess["DataLength"]=datalengthstr;
mess["Metadata.ContentType"]="";
m_fcp->Send(mess);
m_fcp->Send(std::vector<char>(data.begin(),data.end()));
m_log->Debug("FreenetMessageInserter::StartInsert started insert of private message "+mess["Identifier"]);
}
}
}
示例6: Dump
bool BmpClipboardDumper::Dump(POEngine* pEngine)
{
m_strErr.Empty();
m_bAbort = false;
chuwin32::DibBitmap dib;
if( !PrepareDib(dib, m_strErr) )
{
return false;
}
uint32* const pSrc = dib.m_pBits;
const int32 nWidth = dib.GetWidth();
const int32 nHeight = dib.GetHeight();
const int32 nPixelCount = nWidth * nHeight;
Buffer buf24;
if( !buf24.SetSize(nPixelCount * 3) )
{
m_strErr = k_szNotEnoughMemory;
return false;
}
uint8* const pBuf24 = buf24.GetWritePtr();
uint8* pBufTmp24 = pBuf24;
for(int32 i = 0; i < nPixelCount; ++i)
{
uint32 nSrc = pSrc[i];
uint8 r = uint8( (nSrc >> 16) & 0x000000ff);
uint8 g = uint8( (nSrc >> 8) & 0x000000ff);
uint8 b = uint8( (nSrc >> 0) & 0x000000ff);
pBufTmp24[0] = r;
pBufTmp24[1] = g;
pBufTmp24[2] = b;
pBufTmp24 += 3;
}
PngDumpData dd;
dd.pixels = buf24;
dd.width = nWidth;
dd.height = nHeight;
dd.pixelFormat = PF_24bppRgb;
// Determine the file name
DateTime date = DateTime::GetNow();
String strDate = date.FormatDate();
String strTime = date.FormatTime();
String strFileNameBase = L"shot-" + date.Format(DateFormat::Compact);
String strDestDir;
if( m_settings.useDefaultDir )
{
strDestDir = GetTempDir();
if( strDestDir.IsEmpty() )
{
// Cannot get the temp directory. I wonder when this can happen (maybe a bad registry settings ?)
// Anyway, we inform the user
m_strErr = k_szCannotRetrieveTempPath;
return false;
}
}
else
{
if( m_settings.customDir.IsEmpty() )
{
m_strErr = k_szCustomDirIsEmpty;
m_strErr = m_strErr + L"\n";
m_strErr = m_strErr + k_szCustomDirIsEmpty2;
return false;
}
strDestDir = m_settings.customDir;
}
strDestDir = FilePath::AddSeparator(strDestDir);
String strFileNameFinal = strFileNameBase + L".png";
String strTotalFinalPath = FilePath::Combine(strDestDir, strFileNameFinal);
// Find a unique name
// With the date/time in the name, there is very little chance to get twice the same name,
// but when pasting very fast, one second of delay might be not enough
if( File::Exists(strDestDir + strFileNameFinal) )
{
// Oops
String strCountW;
// 100 tries max, oterwise er... 100 dump in less than one second ?
int32 iCount = 1;
const int32 nMaxCount = 100;
for(; iCount <= nMaxCount; ++iCount)
{
strCountW = L"(" + String::FromInt(iCount) + L")";
strFileNameFinal = strFileNameBase + strCountW + L".png";
if( !File::Exists(strDestDir + strFileNameFinal) )
{
// Found ! ^^
//.........这里部分代码省略.........