Fix: updateNewsToIsmas(): format TIMESTAMP with UTC-Offset suffix.

This commit is contained in:
Gerhard Hoffmann 2024-05-16 10:36:58 +02:00
parent d2a6ae239d
commit f2534c7763

View File

@ -363,7 +363,19 @@ QString IsmasClient::updateNewsToIsmas(char const *event,
char buf[1024]; char buf[1024];
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
QString const ts = QDateTime::currentDateTime().toString(Qt::ISODateWithMs); QDateTime const local(QDateTime::currentDateTime());
QDateTime utc(local);
utc.setTimeSpec(Qt::UTC);
int const diff = (int)local.secsTo(utc); // diff between UTC and local time
QTime t(0, 0, 0);
t = t.addSecs((uint)diff);
QString const st(QString("%1%2").arg(diff < 0 ? "-" : "+").arg(t.toString("hh:mm")));
QString const ts(local.toString(Qt::ISODateWithMs) + st);
snprintf(buf, sizeof(buf)-1, snprintf(buf, sizeof(buf)-1,
"{" "{"
"\"REASON\":\"SW_UP\"," "\"REASON\":\"SW_UP\","