#elif defined(__DARWIN__)
#define WX_GMTOFF_IN_TM
#elif defined(__WXWINCE__) && defined(__VISUALC8__)
+ // _timezone is not present in dynamic run-time library
+ #if 0
+ // Solution (1): use the function equivalent of _timezone
+ static long wxGetTimeZone()
+ {
+ static long s_Timezone = MAXLONG; // invalid timezone
+ if (s_Timezone == MAXLONG)
+ {
+ int t;
+ _get_timezone(& t);
+ s_Timezone = (long) t;
+ }
+ return s_Timezone;
+ }
+ #define WX_TIMEZONE wxGetTimeZone()
+ #elif 1
+ // Solution (2): using GetTimeZoneInformation
+ static long wxGetTimeZone()
+ {
+ static long timezone = MAXLONG; // invalid timezone
+ if (timezone == MAXLONG)
+ {
+ TIME_ZONE_INFORMATION tzi;
+ ::GetTimeZoneInformation(&tzi);
+ timezone = tzi.Bias;
+ }
+ return timezone;
+ }
+ #define WX_TIMEZONE wxGetTimeZone()
+ #else
+ // Old method using _timezone: this symbol doesn't exist in the dynamic run-time library (i.e. using /MD)
#define WX_TIMEZONE _timezone
+ #endif
#else // unknown platform - try timezone
#define WX_TIMEZONE timezone
#endif
#ifdef HAVE_STRFTIME
// this function is a wrapper around strftime(3) adding error checking
-static wxString CallStrftime(const wxChar *format, const tm* tm)
+static wxString CallStrftime(const wxString& format, const tm* tm)
{
wxChar buf[4096];
// Create temp wxString here to work around mingw/cygwin bug 1046059
// wxDateTime to/from text representations
// ----------------------------------------------------------------------------
-wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const
+wxString wxDateTime::Format(const wxString& format, const TimeZone& tz) const
{
- wxCHECK_MSG( format, wxEmptyString, _T("NULL format in wxDateTime::Format") );
+ wxCHECK_MSG( !format.empty(), wxEmptyString,
+ _T("NULL format in wxDateTime::Format") );
// we have to use our own implementation if the date is out of range of
// strftime() or if we use non standard specificators
tmTimeOnly.tm_isdst = 0; // no DST, we adjust for tz ourselves
wxString tmp, res, fmt;
- for ( const wxChar *p = format; *p; p++ )
+ for ( wxString::const_iterator p = format.begin(); p != format.end(); ++p )
{
if ( *p != _T('%') )
{
}
// set the default format
- switch ( *++p )
+ switch ( (*++p).GetValue() )
{
case _T('Y'): // year has 4 digits
fmt = _T("%04d");
restart = false;
// start of the format specification
- switch ( *p )
+ switch ( (*p).GetValue() )
{
case _T('a'): // a weekday name
case _T('A'):
#endif // __WINDOWS__
const wxChar *wxDateTime::ParseFormat(const wxChar *date,
- const wxChar *format,
+ const wxString& format,
const wxDateTime& dateDef)
{
- wxCHECK_MSG( date && format, (wxChar *)NULL,
+ wxCHECK_MSG( date && !format.empty(), (wxChar *)NULL,
_T("NULL pointer in wxDateTime::ParseFormat()") );
wxString str;
int year = 0;
const wxChar *input = date;
- for ( const wxChar *fmt = format; *fmt; fmt++ )
+ for ( wxString::const_iterator fmt = format.begin(); fmt != format.end(); ++fmt )
{
if ( *fmt != _T('%') )
{
// the default widths for the various fields
if ( !width )
{
- switch ( *fmt )
+ switch ( (*fmt).GetValue() )
{
case _T('Y'): // year has 4 digits
width = 4;
}
// then the format itself
- switch ( *fmt )
+ switch ( (*fmt).GetValue() )
{
case _T('a'): // a weekday name
case _T('A'):
// And, to be better than MFC :-), we also have
// %E number of wEeks
// %l milliseconds (000 - 999)
-wxString wxTimeSpan::Format(const wxChar *format) const
+wxString wxTimeSpan::Format(const wxString& format) const
{
- wxCHECK_MSG( format, wxEmptyString, _T("NULL format in wxTimeSpan::Format") );
+ wxCHECK_MSG( !format.empty(), wxEmptyString,
+ _T("NULL format in wxTimeSpan::Format") );
wxString str;
- str.Alloc(wxStrlen(format));
+ str.Alloc(format.length());
// Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */)
//
// we remember the most important unit found so far
TimeSpanPart partBiggest = Part_MSec;
- for ( const wxChar *pch = format; *pch; pch++ )
+ for ( wxString::const_iterator pch = format.begin(); pch != format.end(); ++pch )
{
wxChar ch = *pch;