wxString DateToStr(const wxDateTime &datetime) { if (!datetime.IsValid()) return wxEmptyString; return datetime.FormatDate() + wxT(" ") + datetime.FormatTime(); }
bool wxDatePickerCtrl::Create(wxWindow *parent, wxWindowID id, const wxDateTime& dt, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if(!wxControl::Create(parent, id, pos, size, style, validator, name)) return false; wxString label; if ( dt.IsValid() ) { label = dt.FormatDate(); m_dt = dt; } if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size)) return false; return true; }
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(); }
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; }
wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page) { wxString r = instr; wxString num; num.Printf(wxT("%i"), page); r.Replace(wxT("@PAGENUM@"), num); num.Printf(wxT("%lu"), (unsigned long)(m_PageBreaks.Count() - 1)); r.Replace(wxT("@PAGESCNT@"), num); const wxDateTime now = wxDateTime::Now(); r.Replace(wxT("@DATE@"), now.FormatDate()); r.Replace(wxT("@TIME@"), now.FormatTime()); r.Replace(wxT("@TITLE@"), GetTitle()); return r; }
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); } }
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); } }
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 }