aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive_parser.cpp
diff options
context:
space:
mode:
authorConfuSomu2023-04-04 00:10:58 -0400
committerConfuSomu2023-04-04 00:17:56 -0400
commit3095e11bfaba99fe4fb598a53914b80979aafe0f (patch)
treef573654eed84e75a515f32768b563b828b0bdc40 /src/archive_parser.cpp
parent14294369e2ee7e4914757054693fe77b450f7405 (diff)
downloadActorViewer-3095e11bfaba99fe4fb598a53914b80979aafe0f.tar
ActorViewer-3095e11bfaba99fe4fb598a53914b80979aafe0f.tar.gz
ActorViewer-3095e11bfaba99fe4fb598a53914b80979aafe0f.zip
Display Activity publish date following locale
This is an improved user experience over displaying the raw ISO 8601 date stored in the ActivityStream JSON-LD.
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());