Esempio n. 1
0
// 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);
}
Esempio n. 2
0
bool CDateTime::VerifyFormat(wxString const& fmt)
{
	wxChar buf[4096];
	tm *t = wxDateTime::GetTmNow();

#ifdef __VISUALC__
	CrtAssertSuppressor suppressor;
#endif

	return wxStrftime(buf, sizeof(buf)/sizeof(wxChar), fmt, t) != 0;
}
Esempio n. 3
0
// this function is a wrapper around strftime(3)
// allows to exclude the usage of wxDateTime
static wxString TimeStamp(const wxString& format, time_t t)
{
    wxChar buf[4096];
    struct tm tm;
    if ( !wxStrftime(buf, WXSIZEOF(buf), format, wxLocaltime_r(&t, &tm)) )
    {
        // buffer is too small?
        wxFAIL_MSG(wxT("strftime() failed"));
    }
    return wxString(buf);
}
Esempio n. 4
0
// this function is a wrapper around strftime(3)
// allows to exclude the usage of wxDateTime
static wxString TimeStamp(const wxString& format, time_t t)
{
#if wxUSE_DATETIME
    wxChar buf[4096];
    struct tm tm;
    if ( !wxStrftime(buf, WXSIZEOF(buf), format, wxLocaltime_r(&t, &tm)) )
    {
        // buffer is too small?
        wxFAIL_MSG(_T("strftime() failed"));
    }
    return wxString(buf);
#else // !wxUSE_DATETIME
    return wxEmptyString;
#endif // wxUSE_DATETIME/!wxUSE_DATETIME
}
Esempio n. 5
0
void wxLog::TimeStamp(wxString *str)
{
#if wxUSE_DATETIME
    if ( ms_timestamp )
    {
        wxChar buf[256];
        time_t timeNow;
        (void)time(&timeNow);

        struct tm tm;
        wxStrftime(buf, WXSIZEOF(buf),
                    ms_timestamp, wxLocaltime_r(&timeNow, &tm));

        str->Empty();
        *str << buf << wxT(": ");
    }
#endif // wxUSE_DATETIME
}
Esempio n. 6
0
String
strutil_ftime(time_t time, const String & format, bool gmtflag)
{
   struct tm *tmvalue = gmtflag ? gmtime(&time) : localtime(&time);

   String strTime;
   if ( tmvalue )
   {
      wxChar buffer[256];
      wxStrftime(buffer, 256, format.c_str(), tmvalue);
      strTime = buffer;
   }
   else // this can happen if the message has no valid date header, don't crash!
   {
      strTime = _("invalid");
   }

   return strTime;
}