本文整理汇总了C++中wxDateTime::FormatTime方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDateTime::FormatTime方法的具体用法?C++ wxDateTime::FormatTime怎么用?C++ wxDateTime::FormatTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxDateTime
的用法示例。
在下文中一共展示了wxDateTime::FormatTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDisplayDate
wxString TimerRecordDialog::GetDisplayDate( wxDateTime & dt )
{
#if defined(__WXMSW__)
// On Windows, wxWidgets uses the system date control and it displays the
// date based on the Windows locale selected by the user. But, wxDateTime
// using the strftime function to return the formatted date. Since the
// default locale for the Windows CRT environment is "C", the dates come
// back in a different format.
//
// So, we make direct Windows calls to format the date like it the date
// control.
//
// (Most of this taken from src/msw/datectrl.cpp)
const wxDateTime::Tm tm(dt.GetTm());
SYSTEMTIME st;
wxString s;
int len;
st.wYear = (WXWORD)tm.year;
st.wMonth = (WXWORD)(tm.mon - wxDateTime::Jan + 1);
st.wDay = tm.mday;
st.wDayOfWeek = st.wMinute = st.wSecond = st.wMilliseconds = 0;
len = ::GetDateFormat(LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&st,
NULL,
NULL,
0);
if (len > 0) {
len = ::GetDateFormat(LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&st,
NULL,
wxStringBuffer(s, len),
len);
if (len > 0) {
s += wxT(" ") + dt.FormatTime();
return s;
}
}
#endif
// Use default formatting
wxPrintf(wxT("%s\n"), dt.Format().c_str());
return dt.FormatDate() + wxT(" ") + dt.FormatTime();
}
示例2: eDocumentPath_shouldUpdateCygwin
//
// Returns true if this Cygwin installation should be updated (or installed for the first time.)
// Returns false if we are up-to-date.
//
bool eDocumentPath_shouldUpdateCygwin(wxDateTime &stampTime, const wxFileName &supportFile){
// E's support folder comes with a network installer for Cygwin.
// Newer versions of E may come with newer Cygwin versions.
// If the user already has Cygwin installed, we still check the
// bundled installer to see if it is newer; if so, then we need to
// re-install Cygwin at the newer version.
if (!stampTime.IsValid())
return true; // First time, so we need to update.
wxDateTime updateTime = supportFile.GetModificationTime();
// Windows doesn't store milliseconds; we clear out this part of the time.
updateTime.SetMillisecond(0);
updateTime.SetSecond(0);
stampTime.SetMillisecond(0);
stampTime.SetSecond(0);
// If the times are the same, no update needed.
if (updateTime == stampTime)
return false;
// ...else the dates differ and we need to update.
wxLogDebug(wxT("InitCygwin: Diff dates"));
wxLogDebug(wxT(" e-postinstall: %s"), updateTime.FormatTime());
wxLogDebug(wxT(" last-e-update: %s"), stampTime.FormatTime());
return true;
}
示例3: DateToStr
wxString DateToStr(const wxDateTime &datetime)
{
if (!datetime.IsValid())
return wxEmptyString;
return datetime.FormatDate() + wxT(" ") + datetime.FormatTime();
}
示例4: if
const void *
MyConnection::OnRequest(const wxString& topic,
const wxString& item,
size_t *size,
wxIPCFormat format)
{
*size = 0;
wxString s,
afterDate;
if ( item.StartsWith("Date", &afterDate) )
{
const wxDateTime now = wxDateTime::Now();
if ( afterDate.empty() )
{
s = now.Format();
*size = wxNO_LEN;
}
else if ( afterDate == "+len" )
{
s = now.FormatTime() + " " + now.FormatDate();
*size = strlen(s.mb_str()) + 1;
}
}
else if ( item == "bytes[3]" )
{
s = "123";
*size = 3;
}
if ( !*size )
{
wxLogMessage("Unknown request for \"%s\"", item);
return NULL;
}
// store the data pointer to which we return in a member variable to ensure
// that the pointer remains valid even after we return
m_requestData = s.mb_str();
const void * const data = m_requestData;
Log("OnRequest", topic, item, data, *size, format);
return data;
}
示例5: TranslateHeader
wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
{
wxString r = instr;
wxString num;
num.Printf(wxT("%i"), page);
r.Replace(wxT("@[email protected]"), num);
num.Printf(wxT("%lu"), (unsigned long)(m_PageBreaks.Count() - 1));
r.Replace(wxT("@[email protected]"), num);
const wxDateTime now = wxDateTime::Now();
r.Replace(wxT("@[email protected]"), now.FormatDate());
r.Replace(wxT("@[email protected]"), now.FormatTime());
r.Replace(wxT("@TITL[email protected]"), GetTitle());
return r;
}
示例6: Advise
void MyServer::Advise()
{
if ( CanAdvise() )
{
const wxDateTime now = wxDateTime::Now();
m_connection->Advise(m_connection->m_advise, now.Format());
const wxString s = now.FormatTime() + " " + now.FormatDate();
m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN);
#if wxUSE_DDE_FOR_IPC
wxLogMessage("DDE Advise type argument cannot be wxIPC_PRIVATE. "
"The client will receive it as wxIPC_TEXT, "
" and receive the correct no of bytes, "
"but not print a correct log entry.");
#endif
char bytes[3] = { '1', '2', '3' };
m_connection->Advise(m_connection->m_advise, bytes, 3, wxIPC_PRIVATE);
}
}
示例7: Advise
void MyServer::Advise()
{
if ( CanAdvise() )
{
const wxDateTime now = wxDateTime::Now();
wxString str = wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82");
m_connection->Advise(m_connection->m_advise, str + " (using UTF-8)");
str += " (using wchar_t)";
m_connection->Advise(m_connection->m_advise,
str.wc_str(), (str.length() + 1)*sizeof(wchar_t),
wxIPC_UNICODETEXT);
// This one uses wxIPC_TEXT by default.
const wxString s = now.FormatTime() + " " + now.FormatDate();
m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN);
char bytes[3] = { '1', '2', '3' };
m_connection->Advise(m_connection->m_advise, bytes, 3, wxIPC_PRIVATE);
}
}
示例8: SetDirModDate
void BundleManager::SetDirModDate(wxFileName& path, const wxDateTime& modDate) {
#ifdef __WXMSW__
wxLogDebug(wxT("SetDirModDate: %s %s"), modDate.FormatDate(), modDate.FormatTime());
HANDLE hDir = ::CreateFile (
path.GetPath(),
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
FILETIME ftWrite;
ConvertWxToFileTime(&ftWrite, modDate);
::SetFileTime(hDir, &ftWrite, &ftWrite, &ftWrite);
::CloseHandle(hDir);
#else
path.SetTimes(NULL, &modDate, NULL);
#endif
}