1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-27 15:02:50 -05:00

locale-aware clock and date formatting

This commit is contained in:
bbedward
2025-09-02 13:37:33 -04:00
parent 3eddef40fb
commit 544a17b0db
5 changed files with 71 additions and 29 deletions

View File

@@ -37,10 +37,13 @@ Rectangle {
spacing: Theme.spacingS
StyledText {
text: SettingsData.use24HourClock ? Qt.formatTime(
root.currentDate,
"HH:mm") : Qt.formatTime(
root.currentDate, "h:mm AP")
text: {
if (SettingsData.use24HourClock) {
return root.currentDate.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
} else {
return root.currentDate.toLocaleTimeString(Qt.locale(), "h:mm AP")
}
}
font.pixelSize: Theme.fontSizeMedium - 1
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
@@ -55,7 +58,12 @@ Rectangle {
}
StyledText {
text: Qt.formatDate(root.currentDate, SettingsData.clockDateFormat)
text: {
if (SettingsData.clockDateFormat && SettingsData.clockDateFormat.length > 0) {
return root.currentDate.toLocaleDateString(Qt.locale(), SettingsData.clockDateFormat)
}
return root.currentDate.toLocaleDateString(Qt.locale(), "ddd d")
}
font.pixelSize: Theme.fontSizeMedium - 1
color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter