#include "DateUtils.h"

DateUtils::DateUtils(QObject *parent) : QObject(parent) {
}

QDateTime DateUtils::getMoscowNow() {
    const QTimeZone moscowTimeZone("Europe/Moscow");
    return QDateTime::currentDateTime().toTimeZone(moscowTimeZone);
}

QDateTime DateUtils::getUtcNow() {
    return QDateTime::currentDateTimeUtc();
}

QDateTime DateUtils::fromUtcString(const QString &timestamp) {
    QDateTime dateTime = QDateTime::fromString(timestamp, "yyyy-MM-dd HH:mm:ss");
    if (dateTime.isValid()) {
        dateTime.setTimeZone(QTimeZone::utc());
    }
    return dateTime;
}

QString DateUtils::toUtcString(const QDateTime &dateTime) {
    return dateTime.toString("yyyy-MM-dd HH:mm:ss");
}
