From af309e6d96d5dc5b05ea603539c38ae4e0169e1c Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Tue, 20 Jun 2017 18:50:54 +0400 Subject: [PATCH] Add minus sign (U+2212) as a time zone offset indicator --- src/common/datetimefmt.cpp | 15 +++++++++++---- tests/datetime/datetimetest.cpp | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 30964b3106..1ce36770ac 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -1497,12 +1497,19 @@ wxDateTime::ParseFormat(const wxString& date, break; } - // and then check that it's either plus or minus sign + // Check if there's either a plus, hyphen-minus, or + // minus sign. bool minusFound; - if ( *input == wxT('-') ) - minusFound = true; - else if ( *input == wxT('+') ) + if ( *input == wxS('+') ) minusFound = false; + else if + ( + *input == wxS('-') +#if wxUSE_UNICODE + || *input == wxString::FromUTF8("\xe2\x88\x92") +#endif + ) + minusFound = true; else return false; // no match diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 25907d1318..4b407760a3 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -918,6 +918,11 @@ void DateTimeTestCase::TestTimeZoneParse() { "09:07-04:30", true }, { "19:22+05:45", true }, +#if wxUSE_UNICODE + // Containing minus sign (U+2212) as separator between time and tz. + { "09:37" "\xe2\x88\x92" "0400", true }, +#endif + // Some invalid ones too. { "00:00-1300" }, // Offset out of range. @@ -937,7 +942,7 @@ void DateTimeTestCase::TestTimeZoneParse() for ( size_t n = 0; n < WXSIZEOF(parseTestTimeZones); ++n ) { wxDateTime dt; - wxString sTimeZone = parseTestTimeZones[n].str; + wxString sTimeZone = wxString::FromUTF8(parseTestTimeZones[n].str); wxString::const_iterator end; if ( dt.ParseFormat(sTimeZone, wxS("%H:%M%z"), &end) && end == sTimeZone.end() )