#if !defined(wxUSE_DATETIME) || wxUSE_DATETIME
#ifndef WX_PRECOMP
+ #ifdef __WXMSW__
+ #include "wx/msw/wrapwin.h"
+ #endif
#include "wx/string.h"
#include "wx/log.h"
#include "wx/intl.h"
+ #include "wx/stopwatch.h" // for wxGetLocalTimeMillis()
+ #include "wx/module.h"
#endif // WX_PRECOMP
#include "wx/thread.h"
#include "wx/tokenzr.h"
-#include "wx/module.h"
#include <ctype.h>
#ifdef __WINDOWS__
- #include "wx/msw/wrapwin.h"
#include <winnls.h>
#ifndef __WXWINCE__
#include <locale.h>
#endif
#include "wx/datetime.h"
-#include "wx/stopwatch.h" // for wxGetLocalTimeMillis()
const long wxDateTime::TIME_T_FACTOR = 1000l;
case wxDateTime::GMT10:
case wxDateTime::GMT11:
case wxDateTime::GMT12:
+ case wxDateTime::GMT13:
m_offset = 3600*(tz - wxDateTime::GMT0);
break;
if ( ch == _T('%') )
{
// the start of the format specification of the printf() below
- wxString fmtPrefix = _T('%');
+ wxString fmtPrefix(_T('%'));
// the number
long n;
+ // the number of digits for the format string, 0 if unused
+ unsigned digits = 0;
+
ch = *++pch; // get the format spec char
switch ( ch )
{
n = GetHours();
if ( partBiggest < Part_Hour )
{
+ if ( n < 0 )
+ {
+ // the sign has already been taken into account
+ // when outputting the biggest part
+ n = -n;
+ }
+
n %= HOURS_PER_DAY;
}
else
partBiggest = Part_Hour;
}
- fmtPrefix += _T("02");
+ digits = 2;
break;
case _T('l'):
n = GetMilliseconds().ToLong();
if ( partBiggest < Part_MSec )
{
+ if ( n < 0 )
+ n = -n;
+
n %= 1000;
}
//else: no need to reset partBiggest to Part_MSec, it is
// the least significant one anyhow
- fmtPrefix += _T("03");
+ digits = 3;
break;
case _T('M'):
n = GetMinutes();
if ( partBiggest < Part_Min )
{
+ if ( n < 0 )
+ n = -n;
+
n %= MIN_PER_HOUR;
}
else
partBiggest = Part_Min;
}
- fmtPrefix += _T("02");
+ digits = 2;
break;
case _T('S'):
n = GetSeconds().ToLong();
if ( partBiggest < Part_Sec )
{
+ if ( n < 0 )
+ n = -n;
+
n %= SEC_PER_MIN;
}
else
partBiggest = Part_Sec;
}
- fmtPrefix += _T("02");
+ digits = 2;
break;
}
+ if ( digits )
+ {
+ // negative numbers need one extra position for '-' display
+ if ( n < 0 )
+ digits++;
+
+ fmtPrefix << _T("0") << digits;
+ }
+
str += wxString::Format(fmtPrefix + _T("ld"), n);
}
else