Skip to content

Commit

Permalink
Replace setTimeSpec() calls with setTimeZone()
Browse files Browse the repository at this point in the history
This change should be compatible back to Qt 5.5 (https://doc.qt.io/qt-5/qtimezone.html#utc)
and it removes the deprecation warnings that occur since Qt 6.5
  • Loading branch information
TheComputerGuy96 committed Oct 19, 2024
1 parent a93e2a6 commit 7eba71a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Dialogs/MetaEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QInputDialog>
#include <QTimer>
#include <QDebug>
#include <QTimeZone>

#include "Dialogs/TreeModel.h"
#include "Dialogs/TreeItem.h"
Expand Down Expand Up @@ -474,7 +475,7 @@ void MetaEditor::selectElement()
insertRow(EName(code), code, content, "");
} else if (code == "dcterms:modified") {
QDateTime zt(QDateTime::currentDateTime());
zt.setTimeSpec(Qt::UTC);
zt.setTimeZone(QTimeZone::utc());
QString content = zt.toString(Qt::ISODate);
insertRow(EName(code), code, content, "");
} else if (code == "dc:type") {
Expand Down
5 changes: 3 additions & 2 deletions src/ResourceObjects/OPFResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QRegularExpressionMatch>
#include <QDateTime>
#include <QDebug>
#include <QTimeZone>

#include "BookManipulation/CleanSource.h"
#include "BookManipulation/XhtmlDoc.h"
Expand Down Expand Up @@ -1500,7 +1501,7 @@ QString OPFResource::AddModificationDateMeta()
{
QString datetime;
QDateTime local(QDateTime::currentDateTime());
local.setTimeSpec(Qt::UTC);
local.setTimeZone(QTimeZone::utc());
datetime = local.toString(Qt::ISODate);

QWriteLocker locker(&GetLock());
Expand Down Expand Up @@ -1576,7 +1577,7 @@ QString OPFResource::GetOPFDefaultText(const QString &version)
}
// epub 3 set dcterms:modified date time in ISO 8601 format
QDateTime local(QDateTime::currentDateTime());
local.setTimeSpec(Qt::UTC);
local.setTimeZone(QTimeZone::utc());
QString datetime = local.toString(Qt::ISODate);
return TEMPLATE3_TEXT.arg(Utility::CreateUUID()).arg(defaultLanguage).arg(tr("[Main title here]")).arg(datetime);
}
Expand Down

0 comments on commit 7eba71a

Please sign in to comment.