don't misinterpret the time after the date as a weekday (patch 1836708)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-12-15 21:03:21 +00:00
parent 3f0640b0a8
commit 804eeca5d5
3 changed files with 42 additions and 3 deletions

View File

@ -291,6 +291,10 @@ wxX11:
2.8.8 2.8.8
----- -----
All:
- Fixed bug with parsing some dates in wxDateTime (Bob Pesner)
All (GUI): All (GUI):
- Added wxWindow::GetNextSibling() and GetPrevSibling() - Added wxWindow::GetNextSibling() and GetPrevSibling()

View File

@ -3963,8 +3963,8 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
} }
else // not a valid month name else // not a valid month name
{ {
wday = GetWeekDayFromName(token, Name_Full | Name_Abbr); WeekDay wday2 = GetWeekDayFromName(token, Name_Full | Name_Abbr);
if ( wday != Inv_WeekDay ) if ( wday2 != Inv_WeekDay )
{ {
// a week day // a week day
if ( haveWDay ) if ( haveWDay )
@ -3972,6 +3972,8 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date)
break; break;
} }
wday = wday2;
haveWDay = true; haveWDay = true;
} }
else // not a valid weekday name else // not a valid weekday name

View File

@ -189,6 +189,7 @@ private:
CPPUNIT_TEST( TestTimeTicks ); CPPUNIT_TEST( TestTimeTicks );
CPPUNIT_TEST( TestParceRFC822 ); CPPUNIT_TEST( TestParceRFC822 );
CPPUNIT_TEST( TestDateParse ); CPPUNIT_TEST( TestDateParse );
CPPUNIT_TEST( TestDateTimeParse );
CPPUNIT_TEST( TestTimeArithmetics ); CPPUNIT_TEST( TestTimeArithmetics );
CPPUNIT_TEST( TestDSTBug ); CPPUNIT_TEST( TestDSTBug );
CPPUNIT_TEST( TestDateOnly ); CPPUNIT_TEST( TestDateOnly );
@ -205,6 +206,7 @@ private:
void TestTimeTicks(); void TestTimeTicks();
void TestParceRFC822(); void TestParceRFC822();
void TestDateParse(); void TestDateParse();
void TestDateTimeParse();
void TestTimeArithmetics(); void TestTimeArithmetics();
void TestDSTBug(); void TestDSTBug();
void TestDateOnly(); void TestDateOnly();
@ -799,7 +801,7 @@ void DateTimeTestCase::TestDateParse()
// some invalid ones too // some invalid ones too
{ _T("29 Feb 2006") }, { _T("29 Feb 2006") },
{ _T("31/04/06") }, { _T("31/04/06") },
{ _T("bloordyblop") } { _T("bloordyblop") },
}; };
// special cases // special cases
@ -823,6 +825,37 @@ void DateTimeTestCase::TestDateParse()
} }
} }
void DateTimeTestCase::TestDateTimeParse()
{
static const struct ParseTestData
{
const wxChar *str;
Date date; // NB: this should be in UTC
bool good;
} parseTestDates[] =
{
{ _T("Thu 22 Nov 2007 07:40:00 PM"),
{ 22, wxDateTime::Nov, 2007, 19, 40, 0}, true },
};
// special cases
wxDateTime dt;
for ( size_t n = 0; n < WXSIZEOF(parseTestDates); n++ )
{
wxDateTime dt;
if ( dt.ParseDateTime(parseTestDates[n].str) )
{
CPPUNIT_ASSERT( parseTestDates[n].good );
CPPUNIT_ASSERT_EQUAL( parseTestDates[n].date.DT(), dt );
}
else // failed to parse
{
CPPUNIT_ASSERT( !parseTestDates[n].good );
}
}
}
void DateTimeTestCase::TestTimeArithmetics() void DateTimeTestCase::TestTimeArithmetics()
{ {
static const wxDateSpan testArithmData[] = static const wxDateSpan testArithmData[] =