Clock: new approach to bar clock display based on tokens.

This commit is contained in:
LemmyCook
2025-09-19 23:18:59 -04:00
parent 2cd73c265d
commit f3f8b82fdd
8 changed files with 790 additions and 213 deletions
-5
View File
@@ -142,10 +142,6 @@ Singleton {
adapter.location.use12hourFormat = widget.use12HourClock
delete widget.use12HourClock
}
if (widget.reverseDayMonth !== undefined) {
adapter.location.monthBeforeDay = widget.reverseDayMonth
delete widget.reverseDayMonth
}
break
}
@@ -331,7 +327,6 @@ Singleton {
property string name: defaultLocation
property bool useFahrenheit: false
property bool use12hourFormat: false
property bool monthBeforeDay: false
property bool showWeekNumberInCalendar: false
}
+1 -30
View File
@@ -15,36 +15,7 @@ Singleton {
return Math.floor(date / 1000)
}
function formatDate(monthBeforeDay = true) {
let now = date
let dayName = now.toLocaleDateString(Qt.locale(), "ddd")
dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1)
let day = now.getDate()
let suffix
if (day > 3 && day < 21)
suffix = 'th'
else
switch (day % 10) {
case 1:
suffix = "st"
break
case 2:
suffix = "nd"
break
case 3:
suffix = "rd"
break
default:
suffix = "th"
}
let month = now.toLocaleDateString(Qt.locale(), "MMMM")
let year = now.toLocaleDateString(Qt.locale(), "yyyy")
return `${dayName}, ` + (monthBeforeDay ? `${month} ${day}${suffix} ${year}` : `${day}${suffix} ${month} ${year}`)
}
/**
/**
* Formats a Date object into a YYYYMMDD-HHMMSS string.
* @param {Date} [date=new Date()] - The date to format. Defaults to the current date and time.
* @returns {string} The formatted date string.