From: Vadim Zeitlin Date: Sun, 30 Dec 2007 23:35:40 +0000 (+0000) Subject: fix bug with parsing negative time zones in ParseRfc822Date() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1cf57808cb146742378d24faa77b9e9482c86b2b fix bug with parsing negative time zones in ParseRfc822Date() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50955 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index 0ffe732f14..14a1c96cc5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -301,6 +301,7 @@ wxX11: All: - Fixed bug with parsing some dates in wxDateTime (Bob Pesner) +- Fixed bug with parsing negative time zones in wxDateTime::ParseRfc822Date() All (GUI): diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 5028137aa2..4d78cf7ffc 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -418,7 +418,16 @@ public: { public: TimeZone(TZ tz); - TimeZone(wxDateTime_t offset = 0) { m_offset = offset; } + + // create time zone object with the given offset + TimeZone(long offset = 0) { m_offset = offset; } + + static TimeZone Make(long offset) + { + TimeZone tz; + tz.m_offset = offset; + return tz; + } long GetOffset() const { return m_offset; } diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index c80eddf67d..39c81372eb 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -2971,7 +2971,7 @@ const wxChar *wxDateTime::ParseRfc822Date(const wxChar* date) // the spec was correct, construct the date from the values we found Set(day, mon, year, hour, min, sec); - MakeFromTimezone(TimeZone((wxDateTime_t)(offset*SEC_PER_MIN))); + MakeFromTimezone(TimeZone::Make(offset*SEC_PER_MIN)); return p; } diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 8c584dd659..d5e57251a2 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -750,17 +750,23 @@ void DateTimeTestCase::TestParceRFC822() { { _T("Sat, 18 Dec 1999 00:46:40 +0100"), - { 17, wxDateTime::Dec, 1999, 23, 46, 40, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, + { 17, wxDateTime::Dec, 1999, 23, 46, 40 }, true }, { _T("Wed, 1 Dec 1999 05:17:20 +0300"), - { 1, wxDateTime::Dec, 1999, 2, 17, 20, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, + { 1, wxDateTime::Dec, 1999, 2, 17, 20 }, true }, { _T("Sun, 28 Aug 2005 03:31:30 +0200"), - { 28, wxDateTime::Aug, 2005, 1, 31, 30, 0.0, wxDateTime::Inv_WeekDay, 0, 0 }, + { 28, wxDateTime::Aug, 2005, 1, 31, 30 }, + true + }, + + { + _T("Sat, 18 Dec 1999 10:48:30 -0500"), + { 18, wxDateTime::Dec, 1999, 15, 48, 30 }, true }, };