From fc9e1881165ba9d7c0ffa996666cbd2df1f7ded2 Mon Sep 17 00:00:00 2001 From: Blake-Madden <66873089+Blake-Madden@users.noreply.github.com> Date: Sun, 27 Nov 2022 08:42:39 -0500 Subject: [PATCH] Handle 'T' separator in wxDateTime::ParseDateTime() ParseDateTime() currently fails if there is a 'T' separator in front of time component. FormatISOCombined() uses this separator as the default, so wxDateTime can't parse its own formatted results by default. This commit fixes that issue by allowing an optional 'T' between the date and time parts. Closes #22999. --- src/common/datetimefmt.cpp | 4 ++++ tests/datetime/datetimetest.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 18249416d2..33fa84573a 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -1753,6 +1753,10 @@ wxDateTime::ParseDateTime(const wxString& date, wxString::const_iterator *end) while ( endDate != date.end() && wxIsspace(*endDate) ) ++endDate; + // Skip possible 'T' separator in front of time component + if ( endDate != date.end() && *endDate == 'T' ) + ++endDate; + const wxString timestr(endDate, date.end()); if ( !dtTime.ParseTime(timestr, &endTime) ) return false; diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index e0e22353d9..3d4c735342 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -1440,6 +1440,15 @@ void DateTimeTestCase::TestDateTimeParse() false }, + { + // with 'T' separator + "2010-01-04T14:30", + { 4, wxDateTime::Jan, 2010, 14, 30, 0 }, + true, + "", + false + }, + { // date after time "14:30:00 2020-01-04",