summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/filterconstraint.cpp16
-rw-r--r--core/string-format.cpp16
-rw-r--r--core/string-format.h1
3 files changed, 22 insertions, 11 deletions
diff --git a/core/filterconstraint.cpp b/core/filterconstraint.cpp
index bcaf72460..21428b607 100644
--- a/core/filterconstraint.cpp
+++ b/core/filterconstraint.cpp
@@ -7,6 +7,7 @@
#include "qthelper.h"
#include "tag.h"
#include "trip.h"
+#include "string-format.h"
#include "subsurface-string.h"
#include "subsurface-time.h"
#include <QDateTime>
@@ -409,17 +410,10 @@ QStringList filter_contraint_multiple_choice_translated(enum filter_constraint_t
types.append(gettextFromC::tr(divemode_text_ui[i]));
return types;
} else if (type == FILTER_CONSTRAINT_DAY_OF_WEEK) {
- // I can't wrap my head around the fact that Sunday is the
- // first day of the week, but that's how it is.
- return QStringList {
- gettextFromC::tr("Sunday"),
- gettextFromC::tr("Monday"),
- gettextFromC::tr("Tuesday"),
- gettextFromC::tr("Wednesday"),
- gettextFromC::tr("Thursday"),
- gettextFromC::tr("Friday"),
- gettextFromC::tr("Saturday"),
- };
+ QStringList days;
+ for (int i = 0; i < 7; ++i)
+ days.push_back(formatDayOfWeek(i));
+ return days;
}
return QStringList();
}
diff --git a/core/string-format.cpp b/core/string-format.cpp
index 5652a15bf..0ae4e6366 100644
--- a/core/string-format.cpp
+++ b/core/string-format.cpp
@@ -257,3 +257,19 @@ QString formatDiveDateTime(const dive *d)
return QStringLiteral("%1 %2").arg(localTime.date().toString(prefs.date_format_short),
localTime.time().toString(prefs.time_format));
}
+
+QString formatDayOfWeek(int day)
+{
+ // I can't wrap my head around the fact that Sunday is the
+ // first day of the week, but that's how it is.
+ switch (day) {
+ default:
+ case 0: return gettextFromC::tr("Sunday");
+ case 1: return gettextFromC::tr("Monday");
+ case 2: return gettextFromC::tr("Tuesday");
+ case 3: return gettextFromC::tr("Wednesday");
+ case 4: return gettextFromC::tr("Thursday");
+ case 5: return gettextFromC::tr("Friday");
+ case 6: return gettextFromC::tr("Saturday");
+ }
+}
diff --git a/core/string-format.h b/core/string-format.h
index 54a40b890..dfe705344 100644
--- a/core/string-format.h
+++ b/core/string-format.h
@@ -25,5 +25,6 @@ QString formatDiveGPS(const dive *d);
QString formatDiveDate(const dive *d);
QString formatDiveTime(const dive *d);
QString formatDiveDateTime(const dive *d);
+QString formatDayOfWeek(int day);
#endif