fix wxTimeSpan::Format() for negative spans with 0 hour component (#10055)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-12-21 12:16:06 +00:00
parent c0ccc082e2
commit c9e46deaa7
2 changed files with 11 additions and 21 deletions

View File

@@ -4274,6 +4274,14 @@ enum TimeSpanPart
// %l milliseconds (000 - 999)
wxString wxTimeSpan::Format(const wxString& format) const
{
// we deal with only positive time spans here and just add the sign in
// front for the negative ones
if ( IsNegative() )
{
wxString str(Negate().Format(format));
return "-" + str;
}
wxCHECK_MSG( !format.empty(), wxEmptyString,
_T("NULL format in wxTimeSpan::Format") );
@@ -4345,13 +4353,6 @@ wxString wxTimeSpan::Format(const wxString& format) const
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
@@ -4366,9 +4367,6 @@ wxString wxTimeSpan::Format(const wxString& format) const
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
@@ -4381,9 +4379,6 @@ wxString wxTimeSpan::Format(const wxString& format) const
n = GetMinutes();
if ( partBiggest < Part_Min )
{
if ( n < 0 )
n = -n;
n %= MIN_PER_HOUR;
}
else
@@ -4398,9 +4393,6 @@ wxString wxTimeSpan::Format(const wxString& format) const
n = GetSeconds().ToLong();
if ( partBiggest < Part_Sec )
{
if ( n < 0 )
n = -n;
n %= SEC_PER_MIN;
}
else
@@ -4414,10 +4406,6 @@ wxString wxTimeSpan::Format(const wxString& format) const
if ( digits )
{
// negative numbers need one extra position for '-' display
if ( n < 0 )
digits++;
fmtPrefix << _T("0") << digits;
}