From 7ff64c25bab10f5f6083722d551c4a2a57e43d3a Mon Sep 17 00:00:00 2001 From: zyz Date: Wed, 27 Nov 2024 14:43:03 +0800 Subject: [PATCH] fix: Time text changes with time zone (#386) as title Log: Time text changes with time zone Bug: https://pms.uniontech.com/bug-view-287217.html --- src/widgets/timewidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/timewidget.cpp b/src/widgets/timewidget.cpp index 6a433d78..d77846ef 100644 --- a/src/widgets/timewidget.cpp +++ b/src/widgets/timewidget.cpp @@ -63,7 +63,8 @@ void TimeWidget::set24HourFormat(bool use24HourFormat) void TimeWidget::updateLocale(const QString &locale, const QString &shortTimeFormat, const QString &longDateFormat) { - m_locale = locale.isEmpty() ? QLocale::system() : QLocale(locale); + Q_UNUSED(locale); + m_locale = QLocale::system(); // locale.isEmpty() ? QLocale::system() : QLocale(locale); if (!shortTimeFormat.isEmpty()) m_shortTimeFormat = shortTimeFormat; if (!longDateFormat.isEmpty()) @@ -79,6 +80,9 @@ void TimeWidget::refreshTime() m_timeLabel->setText(m_locale.toString(QDateTime::currentDateTime(), shortTimeFormat.at(m_shortTimeIndex) + " AP")); } + // "Ap"/"aP"->"AP" + m_shortTimeFormat.replace(QRegExp("a?p", Qt::CaseInsensitive), "AP"); + QString date_format = shortDateFormat.at(m_shortDateIndex) + " " + weekdayFormat.at(m_weekdayIndex); m_dateLabel->setText(m_locale.toString(QDateTime::currentDateTime(), date_format));