aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/archive_parser.cpp')
-rw-r--r--src/archive_parser.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/archive_parser.cpp b/src/archive_parser.cpp
index d16cd49..2522ffa 100644
--- a/src/archive_parser.cpp
+++ b/src/archive_parser.cpp
@@ -6,6 +6,7 @@
#include <QJsonParseError>
#include <QTextDocument>
#include <QFileInfo>
+#include <QDateTime>
Archive::Archive(QString outbox_filename, ArchiveType archive_type) :
outbox_filename(outbox_filename), archive_type(archive_type) {}
@@ -264,15 +265,19 @@ QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref, int
}
// status_index is assumed to be a valid index
-QString Archive::get_html_status_info(int status_index, int text_zone_width, StatusType status_type) {
+QString Archive::get_html_status_info(int status_index, int text_zone_width, StatusType status_type, QLocale* locale) {
QString info_text(*get_html_status_info_template());
QJsonObject obj = outbox_items->at(status_index).toObject();
if (obj.contains("type") and obj["type"].isString())
info_text.replace("{{type}}", obj["type"].toString());
- if (obj.contains("published") and obj["published"].isString())
- info_text.replace("{{published}}", obj["published"].toString());
+ if (obj.contains("published") and obj["published"].isString()) {
+ // TODO: add a UI setting for configuring the display of local time or UTC time.
+ QDateTime date = QDateTime::fromString(obj["published"].toString(), Qt::ISODate).toLocalTime();
+ // Using QLocale::toString() is forward compatible with Qt 6 as QDateTime::toString() will not return anymore a string in the system locale.
+ info_text.replace("{{published}}", locale->toString(date));
+ }
if (obj.contains("id") and obj["id"].isString())
info_text.replace("{{url-id}}", obj["id"].toString());