From 757a4fa146484412a88a1911bf110a704eaafdec Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 22 May 2020 09:02:12 +0200 Subject: cleanup: set long and short date formats in independent branches The short and long date formats where initialized in a common if-branch. However, inside the if-branch the code rechecked which of the two should be initialized. This could make sense if there was some common code between the two, but there wasn't. Therefore, make this two independent branches to avoid one nesting-level. Signed-off-by: Berthold Stoeger --- core/qthelper.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'core/qthelper.cpp') diff --git a/core/qthelper.cpp b/core/qthelper.cpp index c5ab24427..e1329ca26 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -487,26 +487,26 @@ void initUiLanguage() free((void*)prefs.locale.lang_locale); prefs.locale.lang_locale = copy_qstring(uiLang); - if (!prefs.date_format_override || empty_string(prefs.date_format_short) || empty_string(prefs.date_format)) { + if (!prefs.date_format_override || empty_string(prefs.date_format)) { // derive our standard date format from what the locale gives us - // the short format is fine // the long format uses long weekday and month names, so replace those with the short ones // for time we don't want the time zone designator and don't want leading zeroes on the hours - shortDateFormat = loc.dateFormat(QLocale::ShortFormat); dateFormat = loc.dateFormat(QLocale::LongFormat); dateFormat.replace("dddd,", "ddd").replace("dddd", "ddd").replace("MMMM", "MMM"); // special hack for Swedish as our switching from long weekday names to short weekday names // messes things up there dateFormat.replace("'en' 'den' d:'e'", " d"); - if (!prefs.date_format_override || empty_string(prefs.date_format)) { - free((void *)prefs.date_format); - prefs.date_format = copy_qstring(dateFormat); - } - if (!prefs.date_format_override || empty_string(prefs.date_format_short)) { - free((void *)prefs.date_format_short); - prefs.date_format_short = copy_qstring(shortDateFormat); - } + free((void *)prefs.date_format); + prefs.date_format = copy_qstring(dateFormat); + } + + if (!prefs.date_format_override || empty_string(prefs.date_format_short)) { + // derive our standard date format from what the locale gives us + shortDateFormat = loc.dateFormat(QLocale::ShortFormat); + free((void *)prefs.date_format_short); + prefs.date_format_short = copy_qstring(shortDateFormat); } + if (!prefs.time_format_override || empty_string(prefs.time_format)) { timeFormat = loc.timeFormat(); timeFormat.replace("(t)", "").replace(" t", "").replace("t", "").replace("hh", "h").replace("HH", "H").replace("'kl'.", ""); -- cgit v1.2.3-70-g09d2