X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/df4b7d9894cccf1d3221e07d6a98be670706ae5d..bedaf53eaf4e2a860b34d4ff5e0b1928ce8fa5c9:/src/generic/logg.cpp diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index d52e34447d..0891c8de9a 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -50,6 +50,8 @@ #include "wx/textfile.h" #include "wx/statline.h" +#if wxUSE_LOG + #ifdef __WXMSW__ // for OutputDebugString() #include "wx/msw/private.h" @@ -60,7 +62,6 @@ #define wxUSE_LOG_DIALOG 1 #if wxUSE_LOG_DIALOG - #include "wx/datetime.h" #include "wx/listctrl.h" #include "wx/imaglist.h" #include "wx/image.h" @@ -74,6 +75,20 @@ #if wxUSE_LOG_DIALOG +// this function is a wrapper around strftime(3) +// allows to exclude the usage of wxDateTime +static wxString TimeStamp(const wxChar *format, time_t t) +{ + wxChar buf[4096]; + if ( !wxStrftime(buf, WXSIZEOF(buf), format, localtime(&t)) ) + { + // buffer is too small? + wxFAIL_MSG(_T("strftime() failed")); + } + return wxString(buf); +} + + class wxLogDialog : public wxDialog { public: @@ -861,7 +876,7 @@ void wxLogDialog::CreateDetailsControls() m_listctrl->InsertItem(n, m_messages[n]); m_listctrl->SetItem(n, 1, - wxDateTime((time_t)m_times[n]).Format(fmt)); + TimeStamp(fmt, (time_t)m_times[n])); } // let the columns size themselves @@ -917,7 +932,7 @@ void wxLogDialog::OnSave(wxCommandEvent& WXUNUSED(event)) for ( size_t n = 0; ok && (n < count); n++ ) { wxString line; - line << wxDateTime((time_t)m_times[n]).Format(fmt) + line << TimeStamp(fmt, (time_t)m_times[n]) << _T(": ") << m_messages[n] << wxTextFile::GetEOL(); @@ -1056,3 +1071,4 @@ static int OpenLogFile(wxFile& file, wxString *pFilename) #endif // wxUSE_FILE +#endif // wxUSE_LOG