Files
visuve c56ac5b2cc Add support for Qt 6
- This does compile and run on Qt 6
- Tried not to break Qt 4
2024-04-05 20:51:57 +03:00

20 lines
469 B
C++

#include "DateDisplay.h"
#include <time.h>
QString getDateString(const quint64 timestamp)
{
if (timestamp == 0 || timestamp == (-1)) {
return "";
}
const time_t rawtime = (const time_t)timestamp;
QString format = "dddd, dd.MM.yyyy hh:mm:ss";
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDateTime date1(QDateTime::fromSecsSinceEpoch(rawtime));
#else
QDateTime date1(QDateTime::fromTime_t(rawtime));
#endif
return date1.toUTC().toString(format) + " UTC";
}