diff --git a/docs/changes.txt b/docs/changes.txt index f66c739910..ed565aed01 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -94,6 +94,7 @@ Major new features in 2.8 release 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 1f7074ee04..dd409690b7 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -421,8 +421,21 @@ public: { public: TimeZone(TZ tz); + + // don't use this ctor, it doesn't work for negative offsets (but can't + // be removed or changed to avoid breaking ABI in 2.8) TimeZone(wxDateTime_t offset = 0) { m_offset = offset; } +#if wxABI_VERSION >= 20808 + // create time zone object with the given offset + static TimeZone Make(long offset) + { + TimeZone tz; + tz.m_offset = offset; + return tz; + } +#endif // wxABI 2.8.8+ + long GetOffset() const { return m_offset; } private: diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index c7f2fd6b33..109e3e712b 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -3000,7 +3000,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 db64b5c53e..935d58109d 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -748,17 +748,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 }, }; diff --git a/version-script.in b/version-script.in index 5969a82a8e..533a792ab3 100644 --- a/version-script.in +++ b/version-script.in @@ -27,6 +27,7 @@ # public symbols added in 2.8.8 (please keep in alphabetical order): @WX_VERSION_TAG@.8 { global: + *TimeZone*Make*; *wxScrollHelper*HandleOnChildFocus*; *wxWindowBase*Get*Sibling*; };