From 8ff7f01a1f1f5594d65e79cc2f12a59276099a94 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 4 Jul 2018 13:59:00 +0300 Subject: [PATCH] [Manager] Fix time verification to allow '24:00' value in Preferences dialog Time verification simplification. Signed-off-by: Vitalii Koshura --- clientgui/DlgAdvPreferences.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index d9248704f7..d254f5e2de 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -1006,33 +1006,17 @@ bool CDlgAdvPreferences::IsValidFloatValueBetween(const wxString& value, double /* checks if the value is a valid time */ bool CDlgAdvPreferences::IsValidTimeValue(const wxString& value) { - for(unsigned int i=0; i < value.Length();i++) { - if(!IsValidTimeChar(value[i])) { + for (unsigned int i = 0; i < value.Length(); i++) { + if (!IsValidTimeChar(value[i])) { return false; } } - //verify correct format and range of time values - int h = -1, m = -1; - //verify the format itself - int parsed = sscanf(value.c_str(), "%d:%d", &h, &m); - if (parsed != 2) { - return false; - } - //verify hours - if (h < 0 || h > 23) { - return false; - } - //verify minutes - if (m < 0 || m > 59) { - return false; - } //all chars are valid, now what is with the value as a whole ? + if (value == wxT("24:00")) return true; wxDateTime dt; - const wxChar* stopChar = dt.ParseFormat(value,wxT("%H:%M")); - if(stopChar==NULL && value != wxT("24:00")) { - // conversion failed - return false; - } + const wxChar* stopChar = dt.ParseFormat(value, wxT("%H:%M")); + if (stopChar == NULL) return false; // conversion failed + if (*stopChar != '\0') return false; // conversion failed return true; }