From cf9f6737895ace461dcc8ce55ba56bebb97c6a4b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 1 Jun 2008 14:37:26 +0000 Subject: [PATCH] fix wxDateTime::ParseRfc822Date() to handle missing seconds (ticket #1341) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53900 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetime.cpp | 3 ++- tests/datetime/datetimetest.cpp | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 7fdd2affd1..f6ad3f6259 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -2847,8 +2847,9 @@ wxDateTime::ParseRfc822Date(const wxString& date, wxString::const_iterator *end) min = (wxDateTime_t)(min + *p++ - _T('0')); wxDateTime_t sec = 0; - if ( *p++ == _T(':') ) + if ( *p == _T(':') ) { + p++; if ( !wxIsdigit(*p) ) { return NULL; diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 9fcbd29a25..cc15c73abc 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -767,15 +767,29 @@ void DateTimeTestCase::TestParceRFC822() }, { "Sun, 28 Aug 2005 03:31:30 +0200", - { 28, wxDateTime::Aug, 2005, 1, 31, 30 }, + { 28, wxDateTime::Aug, 2005, 1, 31, 30 }, true }, { "Sat, 18 Dec 1999 10:48:30 -0500", - { 18, wxDateTime::Dec, 1999, 15, 48, 30 }, + { 18, wxDateTime::Dec, 1999, 15, 48, 30 }, true }, + + // seconds are optional according to the RFC + { + "Sun, 01 Jun 2008 16:30 +0200", + { 1, wxDateTime::Jun, 2008, 14, 30, 00 }, + true + }, + + // try some bogus ones too + { + "Sun, 01 Jun 2008 16:30: +0200", + { 0 }, + false + }, }; for ( unsigned n = 0; n < WXSIZEOF(parseTestDates); n++ ) -- 2.45.2