diff --git a/src/gui/filedetails/datefieldbackend.cpp b/src/gui/filedetails/datefieldbackend.cpp index e2dc679f1..5fadabe0c 100644 --- a/src/gui/filedetails/datefieldbackend.cpp +++ b/src/gui/filedetails/datefieldbackend.cpp @@ -14,6 +14,8 @@ #include "datefieldbackend.h" +#include + namespace OCC { namespace Quick @@ -49,5 +51,18 @@ void DateFieldBackend::setDateTimeMsecs(const qint64 dateTimeMsecs) setDateTime(dt); } +QString DateFieldBackend::dateTimeString() const +{ + const auto locale = QLocale::system(); + return m_dateTime.toString(locale.dateTimeFormat(QLocale::ShortFormat)); +} + +void DateFieldBackend::setDateTimeString(const QString &dateTimeString) +{ + const auto locale = QLocale::system(); + const auto dt = locale.toDateTime(dateTimeString, locale.dateTimeFormat(QLocale::ShortFormat)); + setDateTime(dt); +} + } } \ No newline at end of file diff --git a/src/gui/filedetails/datefieldbackend.h b/src/gui/filedetails/datefieldbackend.h index 92e5508c8..b20e17dca 100644 --- a/src/gui/filedetails/datefieldbackend.h +++ b/src/gui/filedetails/datefieldbackend.h @@ -28,16 +28,19 @@ class DateFieldBackend : public QObject Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged) Q_PROPERTY(qint64 dateTimeMsecs READ dateTimeMsecs WRITE setDateTimeMsecs NOTIFY dateTimeChanged) + Q_PROPERTY(QString dateTimeString READ dateTimeString WRITE setDateTimeString NOTIFY dateTimeChanged) public: explicit DateFieldBackend() = default; [[nodiscard]] QDateTime dateTime() const; [[nodiscard]] qint64 dateTimeMsecs() const; + [[nodiscard]] QString dateTimeString() const; public slots: void setDateTime(const QDateTime &dateTime); void setDateTimeMsecs(const qint64 dateTimeMsecs); + void setDateTimeString(const QString &dateTimeString); signals: void dateTimeChanged();