summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-22 09:02:12 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-22 10:00:43 -0700
commit757a4fa146484412a88a1911bf110a704eaafdec (patch)
tree0a661aeb0032d02003c1ea35df3dce7525ba3dd1 /core
parent2bd9138a2488400fceb89c7f74cb77cc2cbbf67d (diff)
downloadsubsurface-757a4fa146484412a88a1911bf110a704eaafdec.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/qthelper.cpp22
1 files changed, 11 insertions, 11 deletions
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'.", "");