Fix bug with parsing time formats during DST periods.
wxDateTime::ParseFormat() used todays date as fall back when parsing all formats, including those involving times, which meant that its results depended on whether DST was active at the time of the parsing which was clearly wrong. Fix this by using a fixed date on which DST is known not to be active as fall back date. This fixes unit test failures in DateTimeTestCase::TestTimeFormat() when it was ran on a DST transition date. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70993 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -291,8 +291,14 @@ ParseFormatAt(wxString::const_iterator& p,
|
||||
const wxString str(p, end);
|
||||
wxString::const_iterator endParse;
|
||||
wxDateTime dt;
|
||||
if ( dt.ParseFormat(str, fmt, &endParse) ||
|
||||
(!fmtAlt.empty() && dt.ParseFormat(str, fmtAlt, &endParse)) )
|
||||
|
||||
// Use a default date outside of the DST period to avoid problems with
|
||||
// parsing the time differently depending on the todays date (which is used
|
||||
// as the fall back date if none is explicitly specified).
|
||||
static const wxDateTime dtDef(1, wxDateTime::Jan, 2012);
|
||||
|
||||
if ( dt.ParseFormat(str, fmt, dtDef, &endParse) ||
|
||||
(!fmtAlt.empty() && dt.ParseFormat(str, fmtAlt, dtDef, &endParse)) )
|
||||
{
|
||||
p += endParse - str.begin();
|
||||
}
|
||||
|
Reference in New Issue
Block a user