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.
This commit is contained in:
Blake-Madden 2022-11-27 08:42:39 -05:00 committed by Vadim Zeitlin
parent b76e2b728a
commit fc9e188116
2 changed files with 13 additions and 0 deletions

View file

@ -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;

View file

@ -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",