adatetime.h 588 B

12345678910111213141516171819202122232425
  1. #ifndef ADATETIME_H
  2. #define ADATETIME_H
  3. #include <QtCore>
  4. #include "src/oplconstants.h"
  5. namespace ADateTime {
  6. /*!
  7. * \brief toString formats a QDateTime object into a string in a uniform way.
  8. * \return
  9. */
  10. inline const QString toString (const QDateTime date_time, Opl::Datetime::DateTimeFormat format) {
  11. switch (format) {
  12. case Opl::Datetime::Default:
  13. return date_time.toString(Qt::ISODate);
  14. case Opl::Datetime::Backup:
  15. return date_time.toString(QStringLiteral("yyyy_MM_dd_T_hh_mm"));
  16. default:
  17. return QString();
  18. }
  19. }
  20. }
  21. #endif // ADATETIME_H