include wx/datetime.h and test for wxUSE_DATETIME before using wxLocaltime_r()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-11-04 23:46:02 +00:00
parent bb7afa499a
commit 7b2d1c74fe
2 changed files with 7 additions and 0 deletions

View File

@@ -37,6 +37,7 @@
#endif //WX_PRECOMP #endif //WX_PRECOMP
#include "wx/apptrait.h" #include "wx/apptrait.h"
#include "wx/datetime.h"
#include "wx/file.h" #include "wx/file.h"
#include "wx/msgout.h" #include "wx/msgout.h"
#include "wx/textfile.h" #include "wx/textfile.h"
@@ -411,6 +412,7 @@ void wxLog::ClearTraceMasks()
void wxLog::TimeStamp(wxString *str) void wxLog::TimeStamp(wxString *str)
{ {
#if wxUSE_DATETIME
if ( ms_timestamp ) if ( ms_timestamp )
{ {
wxChar buf[256]; wxChar buf[256];
@@ -424,6 +426,7 @@ void wxLog::TimeStamp(wxString *str)
str->Empty(); str->Empty();
*str << buf << wxT(": "); *str << buf << wxT(": ");
} }
#endif // wxUSE_DATETIME
} }
void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t) void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t)

View File

@@ -81,6 +81,7 @@
// allows to exclude the usage of wxDateTime // allows to exclude the usage of wxDateTime
static wxString TimeStamp(const wxChar *format, time_t t) static wxString TimeStamp(const wxChar *format, time_t t)
{ {
#if wxUSE_DATETIME
wxChar buf[4096]; wxChar buf[4096];
struct tm tm; struct tm tm;
if ( !wxStrftime(buf, WXSIZEOF(buf), format, wxLocaltime_r(&t, &tm)) ) if ( !wxStrftime(buf, WXSIZEOF(buf), format, wxLocaltime_r(&t, &tm)) )
@@ -89,6 +90,9 @@ static wxString TimeStamp(const wxChar *format, time_t t)
wxFAIL_MSG(_T("strftime() failed")); wxFAIL_MSG(_T("strftime() failed"));
} }
return wxString(buf); return wxString(buf);
#else // !wxUSE_DATETIME
return wxEmptyString;
#endif // wxUSE_DATETIME/!wxUSE_DATETIME
} }