Skip to content

Commit 2ce629d

Browse files
pengfeixxdeepin-bot[bot]
authored andcommitted
fix: Fixed the issue where the time format did not follow the locale
Fixed the issue where the time format did not follow the locale Log: Fixed the issue where the time format did not follow the locale pms: BUG-342705
1 parent 1e3c76e commit 2ce629d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/plugin-datetime/operation/datetimemodel.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,12 @@ void DatetimeModel::setCurrentFormat(int format, int index)
933933

934934
QString DatetimeModel::currentDate()
935935
{
936-
QLocale locale(QLocale::system().name());
936+
QLocale locale;
937+
if (m_regions.contains(m_langCountry)) {
938+
locale = m_regions.value(m_langCountry);
939+
} else {
940+
locale = QLocale(m_localeName);
941+
}
937942
QString week = weekdayFormat() == 1 ? "ddd" : "dddd";
938943
QString dateFormat = shortDateFormat() + " " + week;
939944

@@ -942,7 +947,12 @@ QString DatetimeModel::currentDate()
942947

943948
QString DatetimeModel::currentTime() const
944949
{
945-
QLocale locale(QLocale::system().name());
950+
QLocale locale;
951+
if (m_regions.contains(m_langCountry)) {
952+
locale = m_regions.value(m_langCountry);
953+
} else {
954+
locale = QLocale(m_localeName);
955+
}
946956
QString timeFormat = longTimeFormat();
947957
// remove all occurrences of 't' and '[tttt]' or similar patterns
948958
timeFormat.remove(QRegularExpression("(\\[t+?\\]|t+)"));

0 commit comments

Comments
 (0)