aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2023-08-16 12:33:07 -0400
committerConfuSomu2023-08-16 12:36:57 -0400
commit52add29e0a380618a358fdbaddb612703d36eb90 (patch)
tree1e4889436f8bd785f83e63d2b75a58029aeb518a
parent597d1ae9b3e0e0b8f7f4fc27b674345e5b812c29 (diff)
downloadActorViewer-52add29e0a380618a358fdbaddb612703d36eb90.tar
ActorViewer-52add29e0a380618a358fdbaddb612703d36eb90.tar.gz
ActorViewer-52add29e0a380618a358fdbaddb612703d36eb90.zip
Implement localtime/UTC time display setting
-rw-r--r--src/activitypub/apactivity.cpp5
-rw-r--r--src/activitypub/appost.cpp6
-rw-r--r--src/activitypub/apquestion.cpp11
3 files changed, 15 insertions, 7 deletions
diff --git a/src/activitypub/apactivity.cpp b/src/activitypub/apactivity.cpp
index 5f1c36d..3bc6444 100644
--- a/src/activitypub/apactivity.cpp
+++ b/src/activitypub/apactivity.cpp
@@ -1,5 +1,6 @@
#include "apactivity.h"
#include "apactor.h"
+#include "src/settings_interface.h"
#include <QDebug>
@@ -40,7 +41,9 @@ QString APActivity::get_html_render(HtmlRenderDetails render_info) {
html.replace("{{by}}", by_actor.get_html_render(render_info));
html.replace("{{object}}", object->get_html_render(render_info));
if (published.isValid())
- html.replace("{{published}}", render_info.locale->toString(published.toLocalTime()));
+ html.replace("{{published}}", render_info.locale->toString(
+ SettingsInterface::quick_read_setting("ui/timezone").value<AppSettingsTypes::Timezone>() ? published.toUTC() : published.toLocalTime()
+ ));
return html;
}
diff --git a/src/activitypub/appost.cpp b/src/activitypub/appost.cpp
index dadefe8..24a01f5 100644
--- a/src/activitypub/appost.cpp
+++ b/src/activitypub/appost.cpp
@@ -1,4 +1,5 @@
#include "appost.h"
+#include "src/settings_interface.h"
APPost::APPost(APObjectFields fields) {
for (QString actor_url : fields.to_actors)
@@ -44,9 +45,10 @@ QString APPost::get_html_render(HtmlRenderDetails render_info) {
QString html(get_html_template("appost"));
if (published.isValid()) {
- // TODO: add a UI setting for configuring the display of local time or UTC time.
// Using QLocale::toString() is forward compatible with Qt 6 as QDateTime::toString() will not return anymore a string in the system locale.
- html.replace("{{published}}", render_info.locale->toString(published.toLocalTime()));
+ html.replace("{{published}}", render_info.locale->toString(
+ SettingsInterface::quick_read_setting("ui/timezone").value<AppSettingsTypes::Timezone>() ? published.toUTC() : published.toLocalTime()
+ ));
}
html.replace("{{url-id}}", object_url);
diff --git a/src/activitypub/apquestion.cpp b/src/activitypub/apquestion.cpp
index d519947..06fde9e 100644
--- a/src/activitypub/apquestion.cpp
+++ b/src/activitypub/apquestion.cpp
@@ -1,4 +1,5 @@
#include "apquestion.h"
+#include "src/settings_interface.h"
#include <QDebug>
APQuestion::APQuestion(APObjectFields fields) : APPost(fields) {
@@ -18,12 +19,14 @@ QString APQuestion::get_html_render(HtmlRenderDetails render_info) {
html.append(get_html_template("appoll"));
if (end_time.isValid()) {
- // TODO: add a UI setting for configuring the display of local time or UTC time.
- html.replace("{{end-time}}", render_info.locale->toString(end_time.toLocalTime()));
+ html.replace("{{end-time}}", render_info.locale->toString(
+ SettingsInterface::quick_read_setting("ui/timezone").value<AppSettingsTypes::Timezone>() ? end_time.toUTC() : end_time.toLocalTime()
+ ));
}
if (closed_time.isValid()) {
- // TODO: add a UI setting for configuring the display of local time or UTC time.
- html.replace("{{closed-time}}", render_info.locale->toString(closed_time.toLocalTime()));
+ html.replace("{{closed-time}}", render_info.locale->toString(
+ SettingsInterface::quick_read_setting("ui/timezone").value<AppSettingsTypes::Timezone>() ? closed_time.toUTC() : closed_time.toLocalTime()
+ ));
}
html.replace("{{total-votes}}", render_info.locale->toString(total_votes));