From 8b7d411f1406c470e87be9ab225906ba7fd24aa2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Jan 2010 11:05:47 +0000 Subject: [PATCH] Correctly parse times without seconds in wxDateTime::ParseTime(). This was always supposed to work but never did because of a typo in the "24 hour format without seconds" format specification. Fix this by removing the extra "%S" from it and add a test for this case. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetimefmt.cpp | 2 +- tests/datetime/datetimetest.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index cf02a55357..f9404d8642 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -1941,7 +1941,7 @@ wxDateTime::ParseTime(const wxString& time, wxString::const_iterator *end) "%I:%M:%S %p", // 12hour with AM/PM "%H:%M:%S", // could be the same or 24 hour one so try it too "%I:%M %p", // 12hour with AM/PM but without seconds - "%H:%M:%S", // and a possibly 24 hour version without seconds + "%H:%M", // and a possibly 24 hour version without seconds "%X", // possibly something from above or maybe something // completely different -- try it last diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 4731265645..c5766444db 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -1099,8 +1099,23 @@ void DateTimeTestCase::TestDateTimeParse() bool good; } parseTestDates[] = { - { "Thu 22 Nov 2007 07:40:00 PM", - { 22, wxDateTime::Nov, 2007, 19, 40, 0}, true }, + { + "Thu 22 Nov 2007 07:40:00 PM", + { 22, wxDateTime::Nov, 2007, 19, 40, 0 }, + true + }, + + { + "2010-01-04 14:30", + { 4, wxDateTime::Jan, 2010, 14, 30, 0 }, + true + }, + + { + "bloordyblop", + { }, + false + }, }; // the test strings here use "PM" which is not available in all locales so -- 2.47.2