From: Vadim Zeitlin Date: Sat, 9 Jun 2001 17:00:36 +0000 (+0000) Subject: fixed bug 419079 (wxDateTime::ParseTime() didn't find am/pm) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c7f9a482ec133654eac39cde8d736c0476fd4a46?hp=c4d305b7bd7c0889bb6300775d66d31bf42a5e4a fixed bug 419079 (wxDateTime::ParseTime() didn't find am/pm) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 5b8f33ddb3..02ab38450c 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -3371,8 +3371,12 @@ const wxChar *wxDateTime::ParseTime(const wxChar *time) } } - // try all time formats we may think about starting with the standard one - const wxChar *result = ParseFormat(time, _T("%X")); + // try all time formats we may think about in the order from longest to + // shortest + + // 12hour with AM/PM? + const wxChar *result = ParseFormat(time, _T("%I:%M:%S %p")); + if ( !result ) { // normally, it's the same, but why not try it? @@ -3381,8 +3385,8 @@ const wxChar *wxDateTime::ParseTime(const wxChar *time) if ( !result ) { - // 12hour with AM/PM? - result = ParseFormat(time, _T("%I:%M:%S %p")); + // 12hour with AM/PM but without seconds? + result = ParseFormat(time, _T("%I:%M %p")); } if ( !result ) @@ -3393,8 +3397,8 @@ const wxChar *wxDateTime::ParseTime(const wxChar *time) if ( !result ) { - // 12hour with AM/PM but without seconds? - result = ParseFormat(time, _T("%I:%M %p")); + // just the hour and AM/PM? + result = ParseFormat(time, _T("%I %p")); } if ( !result ) @@ -3405,8 +3409,9 @@ const wxChar *wxDateTime::ParseTime(const wxChar *time) if ( !result ) { - // just the hour and AM/PM? - result = ParseFormat(time, _T("%I %p")); + // parse the standard format: normally it is one of the formats above + // but it may be set to something completely different by the user + result = ParseFormat(time, _T("%X")); } // TODO: parse timezones