Skip to content

Commit

Permalink
fix: Time text changes with time zone (#386)
Browse files Browse the repository at this point in the history
as title

Log: Time text changes with time zone
Bug: https://pms.uniontech.com/bug-view-287217.html
  • Loading branch information
yixinshark authored Nov 27, 2024
1 parent 510ab68 commit 7ff64c2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/widgets/timewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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));

Expand Down

0 comments on commit 7ff64c2

Please sign in to comment.