aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-02-26 11:55:50 +0000
committersaturneric <[email protected]>2024-02-26 11:55:50 +0000
commit17b37d58534c1577be6fdfccc3ad6168d11cc5e4 (patch)
tree658a59a517fbcb464e8a6eb5ff04d9a4996d0b34
parentfix: improve icons and logo style (diff)
downloadGpgFrontend-17b37d58534c1577be6fdfccc3ad6168d11cc5e4.tar.gz
GpgFrontend-17b37d58534c1577be6fdfccc3ad6168d11cc5e4.zip
fix: show the real UTC datetime
-rw-r--r--src/core/function/result_analyse/GpgSignResultAnalyse.cpp6
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp11
-rw-r--r--src/core/utils/LocalizedUtils.cpp7
-rw-r--r--src/core/utils/LocalizedUtils.h6
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp7
5 files changed, 22 insertions, 15 deletions
diff --git a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
index 3f3040b8..e02996b3 100644
--- a/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgSignResultAnalyse.cpp
@@ -103,11 +103,9 @@ void GpgSignResultAnalyse::doAnalyse() {
stream_ << "- " << tr("Hash Algo") << ": "
<< gpgme_hash_algo_name(new_sign->hash_algo) << Qt::endl;
stream_ << "- " << tr("Sign Date") << "(" << tr("UTC") << ")"
- << ": "
- << QDateTime::fromSecsSinceEpoch(new_sign->timestamp).toString()
- << Qt::endl;
+ << ": " << GetUTCDateByTimestamp(new_sign->timestamp) << Qt::endl;
stream_ << "- " << tr("Sign Date") << "(" << tr("Localized") << ")"
- << ": " << GetFormatedDateByTimestamp(new_sign->timestamp)
+ << ": " << GetLocalizedDateByTimestamp(new_sign->timestamp)
<< Qt::endl;
stream_ << Qt::endl
diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
index df6b58b0..0a098a93 100644
--- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
@@ -55,11 +55,10 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() {
auto *sign = result->signatures;
stream_ << "-> " << tr("Signed On") << "(" << tr("UTC") << ")"
- << ": " << QDateTime::fromSecsSinceEpoch(sign->timestamp).toString()
- << Qt::endl;
+ << ": " << GetUTCDateByTimestamp(sign->timestamp) << Qt::endl;
stream_ << "-> " << tr("Signed On") << "(" << tr("Localized") << ")"
- << ": " << GetFormatedDateByTimestamp(sign->timestamp) << Qt::endl;
+ << ": " << GetLocalizedDateByTimestamp(sign->timestamp) << Qt::endl;
stream_ << Qt::endl << "## " << tr("Signatures List") << ":" << Qt::endl;
stream_ << Qt::endl;
@@ -190,7 +189,8 @@ auto GpgFrontend::GpgVerifyResultAnalyse::print_signer_without_key(
<< Qt::endl;
stream << "- " << tr("Hash Algo") << ": " << sign.GetHashAlgo() << Qt::endl;
stream << "- " << tr("Sign Date") << "(" << tr("UTC") << ")"
- << ": " << sign.GetCreateTime().toString() << Qt::endl;
+ << ": " << QLocale().toString(sign.GetCreateTime().toUTC())
+ << Qt::endl;
stream << "- " << tr("Sign Date") << "(" << tr("Localized") << ")"
<< ": " << QLocale().toString(sign.GetCreateTime()) << Qt::endl;
return true;
@@ -235,7 +235,8 @@ auto GpgFrontend::GpgVerifyResultAnalyse::print_signer(QTextStream &stream,
<< Qt::endl;
stream << "- " << tr("Hash Algo") << ": " << sign.GetHashAlgo() << Qt::endl;
stream << "- " << tr("Sign Date") << "(" << tr("UTC") << ")"
- << ": " << sign.GetCreateTime().toString() << Qt::endl;
+ << ": " << QLocale().toString(sign.GetCreateTime().toUTC())
+ << Qt::endl;
stream << "- " << tr("Sign Date") << "(" << tr("Localized") << ")"
<< ": " << QLocale().toString(sign.GetCreateTime()) << Qt::endl;
stream << Qt::endl;
diff --git a/src/core/utils/LocalizedUtils.cpp b/src/core/utils/LocalizedUtils.cpp
index 6c020ed7..e5c9b434 100644
--- a/src/core/utils/LocalizedUtils.cpp
+++ b/src/core/utils/LocalizedUtils.cpp
@@ -32,7 +32,12 @@
namespace GpgFrontend {
-auto GetFormatedDateByTimestamp(time_t timestamp) -> QString {
+auto GetLocalizedDateByTimestamp(time_t timestamp) -> QString {
return QLocale().toString(QDateTime::fromSecsSinceEpoch(timestamp));
}
+
+auto GetUTCDateByTimestamp(time_t timestamp) -> QString {
+ return QLocale().toString(QDateTime::fromSecsSinceEpoch(timestamp).toUTC());
+}
+
} // namespace GpgFrontend
diff --git a/src/core/utils/LocalizedUtils.h b/src/core/utils/LocalizedUtils.h
index d7aaf0c8..b93b500c 100644
--- a/src/core/utils/LocalizedUtils.h
+++ b/src/core/utils/LocalizedUtils.h
@@ -30,6 +30,8 @@
namespace GpgFrontend {
-auto GPGFRONTEND_CORE_EXPORT GetFormatedDateByTimestamp(time_t) -> QString;
+auto GPGFRONTEND_CORE_EXPORT GetLocalizedDateByTimestamp(time_t) -> QString;
-} \ No newline at end of file
+auto GPGFRONTEND_CORE_EXPORT GetUTCDateByTimestamp(time_t) -> QString;
+
+} // namespace GpgFrontend \ No newline at end of file
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 6f0a99fb..61c5de56 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -101,8 +101,9 @@ void MainWindow::slot_append_keys_create_datetime() {
auto create_datetime_format_str_local =
QLocale().toString(key.GetCreateTime()) + " (" + tr("Localize") + ") " +
"\n";
- auto create_datetime_format_str = key.GetCreateTime().toString(Qt::ISODate) +
- " (" + tr("UTC") + ") " + "\n ";
+ auto create_datetime_format_str =
+ QLocale().toString(key.GetCreateTime().toUTC()) + " (" + tr("UTC") +
+ ") " + "\n ";
edit_->SlotAppendText2CurTextPage(create_datetime_format_str_local +
create_datetime_format_str);
}
@@ -125,7 +126,7 @@ void MainWindow::slot_append_keys_expire_datetime() {
QLocale().toString(key.GetCreateTime()) + " (" + tr("Local Time") + ") " +
"\n";
auto expire_datetime_format_str =
- key.GetCreateTime().toString(Qt::ISODate) + " (UTC) " + "\n";
+ QLocale().toString(key.GetCreateTime().toUTC()) + " (UTC) " + "\n";
edit_->SlotAppendText2CurTextPage(expire_datetime_format_str_local +
expire_datetime_format_str);