9 const inline static QString ISO_FORMAT_STRING = QStringLiteral(
"yyyy-MM-dd");
10 const inline static QString DE_FORMAT_STRING = QStringLiteral(
"dd.MM.yyyy");
11 const inline static QString EN_FORMAT_STRING = QStringLiteral(
"MM/dd/yyyy");
13 const static inline QMap<OPL::DateFormat, QString> DATEFORMATSMAP = {
14 {OPL::DateFormat::ISODate, ISO_FORMAT_STRING},
15 {OPL::DateFormat::DE, DE_FORMAT_STRING },
16 {OPL::DateFormat::EN, EN_FORMAT_STRING },
20 const static inline QStringList DISPLAY_NAMES = {
21 QStringLiteral(
"ISO 8601: yyyy-MM-dd"),
22 QStringLiteral(
"DE: dd.MM.yyyy"),
23 QStringLiteral(
"EN: MM/dd/yyyy")
31 return date.toString(DATEFORMATSMAP.value(format));
50 static void padZeroes(QString &io_user_input);
52 static void addSeperators(QString &io_user_input,
const OPL::DateFormat &format);
54 static bool containsSeperator(
const QString &user_input);
58 static const QStringList& getDisplayNames();
72 static inline const QString
dateTimeToString (
const QDateTime& date_time, OPL::DateTimeFormat format) {
74 case OPL::DateTimeFormat::Default:
75 return date_time.toString(Qt::ISODate);
76 case OPL::DateTimeFormat::Backup:
77 return date_time.toString(QStringLiteral(
"yyyy_MM_dd_T_hh_mm"));
83 static inline QDateTime fromString(
const QString& date_time_string)
85 auto date_time = QDateTime::fromString(date_time_string, QStringLiteral(
"yyyy-MM-ddhh:mm"));
86 date_time.setTimeZone(QTimeZone::utc());
static void padZeroes(QString &io_user_input)
pads a user-provided date string with 0s to facilitate conversion to QDate
Definition: datetime.cpp:69
static QDate parseInput(QString &user_input, OPL::DateFormat format)
takes a user-provided input and tries to convert it to a (valid) QDate.
Definition: datetime.cpp:5
static void padCentury(QString &io_user_input, OPL::DateFormat format)
padCentury adds the century to a date where it was omitted
Definition: datetime.cpp:38
static const QString currentDate()
today Returns a string containing the current date in ISO format
Definition: datetime.cpp:137
static const QString dateTimeToString(const QDateTime &date_time, OPL::DateTimeFormat format)
dateTimeToString formats a QDateTime object into a string in a uniform way.
Definition: datetime.h:72
static QString dateToString(const QDate &date, OPL::DateFormat format=OPL::DateFormat::ISODate)
Reimplements QDate::toString to accept OPL::Date::DateFormat enums.
Definition: datetime.h:29
A namespace to collect constants and enums used throughout the application.
Definition: paths.cpp:3
DateFormat
ADateFormats enumerates the accepted date formats for QDateEdits.
Definition: opl.h:92