From 0dc258f82ece4f5f690e5cd77b85fbddf2b11ce6 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sat, 22 Oct 2016 23:38:23 +0200 Subject: [PATCH] Warn user about wrong characters in date/time format strings To: subsurface@subsurface-divelog.org fixes #1098 Signed-off-by: Robert C. Helling --- desktop-widgets/preferences/preferences_language.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/desktop-widgets/preferences/preferences_language.cpp b/desktop-widgets/preferences/preferences_language.cpp index 3a6720b..dbcffcc 100644 --- a/desktop-widgets/preferences/preferences_language.cpp +++ b/desktop-widgets/preferences/preferences_language.cpp @@ -70,4 +70,15 @@ void PreferencesLanguage::syncSettings() lang->setDateFormat(ui->dateFormatEntry->text()); lang->setDateFormatShort(ui->shortDateFormatEntry->text()); uiLanguage(NULL); + + QRegExp tfillegalchars("[^hHmszaApPt\\s:;\\.,]"); + if (tfillegalchars.indexIn(ui->timeFormatEntry->text()) >= 0) + QMessageBox::warning(this, tr("Literal characters"), + tr("Non-special character(s) in time format.\nThese will be used as is. This might not be what you intended.\nSee http://doc.qt.io/qt-5/qdatetime.html#toString")); + + QRegExp dfillegalchars("[^dMy/\\s:;\\.,]"); + if (dfillegalchars.indexIn(ui->dateFormatEntry->text()) >= 0 || + dfillegalchars.indexIn(ui->shortDateFormatEntry->text()) >= 0) + QMessageBox::warning(this, tr("Literal characters"), + tr("Non-special character(s) in time format.\nThese will be used as is. This might not be what you intended.\nSee http://doc.qt.io/qt-5/qdatetime.html#toString")); } -- 2.8.4 (Apple Git-73)