fixed several bugs in ParseDate() (invalid dates could result in assert failure while some valid dates such as 29 Feb 2004 were not recognized)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38255 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -49,6 +49,7 @@ All:
|
|||||||
- Albanian translation added (Besnik Bleta)
|
- Albanian translation added (Besnik Bleta)
|
||||||
- Assert messages now show the function in which assert failed
|
- Assert messages now show the function in which assert failed
|
||||||
- wxApp::OnAssertFailure() should now be used instead the old wxApp::OnAssert()
|
- wxApp::OnAssertFailure() should now be used instead the old wxApp::OnAssert()
|
||||||
|
- Fixed several bugs in wxDateTime::ParseDate()
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
|
@@ -3817,9 +3817,11 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
|
|||||||
}
|
}
|
||||||
else // may be either day or year
|
else // may be either day or year
|
||||||
{
|
{
|
||||||
|
// use a leap year if we don't have the year yet to allow
|
||||||
|
// dates like 2/29/1976 which would be rejected otherwise
|
||||||
wxDateTime_t max_days = (wxDateTime_t)(
|
wxDateTime_t max_days = (wxDateTime_t)(
|
||||||
haveMon
|
haveMon
|
||||||
? GetNumOfDaysInMonth(haveYear ? year : Inv_Year, mon)
|
? GetNumOfDaysInMonth(haveYear ? year : 1976, mon)
|
||||||
: 31
|
: 31
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3972,7 +3974,7 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
|
|||||||
{
|
{
|
||||||
wxLogDebug(_T("ParseDate: no day, no weekday hence no date."));
|
wxLogDebug(_T("ParseDate: no day, no weekday hence no date."));
|
||||||
|
|
||||||
return (wxChar *)NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( haveWDay && (haveMon || haveYear || haveDay) &&
|
if ( haveWDay && (haveMon || haveYear || haveDay) &&
|
||||||
@@ -3981,7 +3983,7 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
|
|||||||
// without adjectives (which we don't support here) the week day only
|
// without adjectives (which we don't support here) the week day only
|
||||||
// makes sense completely separately or with the full date
|
// makes sense completely separately or with the full date
|
||||||
// specification (what would "Wed 1999" mean?)
|
// specification (what would "Wed 1999" mean?)
|
||||||
return (wxChar *)NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !haveWDay && haveYear && !(haveDay && haveMon) )
|
if ( !haveWDay && haveYear && !(haveDay && haveMon) )
|
||||||
@@ -4011,7 +4013,7 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
|
|||||||
// if we give the year, month and day must be given too
|
// if we give the year, month and day must be given too
|
||||||
wxLogDebug(_T("ParseDate: day and month should be specified if year is."));
|
wxLogDebug(_T("ParseDate: day and month should be specified if year is."));
|
||||||
|
|
||||||
return (wxChar *)NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4027,6 +4029,11 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
|
|||||||
|
|
||||||
if ( haveDay )
|
if ( haveDay )
|
||||||
{
|
{
|
||||||
|
// normally we check the day above but the check is optimistic in case
|
||||||
|
// we find the day before its month/year so we have to redo it now
|
||||||
|
if ( day > GetNumOfDaysInMonth(year, mon) )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
Set(day, mon, year);
|
Set(day, mon, year);
|
||||||
|
|
||||||
if ( haveWDay )
|
if ( haveWDay )
|
||||||
|
Reference in New Issue
Block a user