12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef ADATETIME_H
- #define ADATETIME_H
- #include <QtCore>
- #include "src/opl.h"
- namespace ADateTime {
- inline const QString toString (const QDateTime& date_time, OPL::DateTimeFormat format) {
- switch (format) {
- case OPL::DateTimeFormat::Default:
- return date_time.toString(Qt::ISODate);
- case OPL::DateTimeFormat::Backup:
- return date_time.toString(QStringLiteral("yyyy_MM_dd_T_hh_mm"));
- default:
- return QString();
- }
- }
- inline QDateTime fromString(const QString& date_time_string)
- {
- auto date_time = QDateTime::fromString(date_time_string, QStringLiteral("yyyy-MM-ddhh:mm"));
- date_time.setTimeZone(QTimeZone::utc());
- return date_time;
- }
- }
- #endif
|