nothing earth shattering but for future ref i did find way to keep it on the 12hr clock while allowing the hh:mm to fill the full width of a vertical panel (task bar).
ground work: first of all the default panel (and kubuntu panel) both have extra padding that prevents the clock from fully using the width of a vertical panel, so the first thing to do is add a new blank panel and migrate all of your task bar widgets over to the new panel… this will give you a few extra pixels to work with.
the next bit, which is optional, is to download and install some narrow (condensed) fonts to play with from fontspace.com … i particularly like Bernound (shown), or Ignotum, but there the Uroob font that comes with kubuntu looks nice too.
the trick as you point out is to edit the
/usr/share/plasma/plasmoids/org.kde.plasma.digitalclock/contents/ui/DigitalClock.qml
file, which will need to be repeated every time there is an update, but it is what it is.
around line 600 or so you will find the block of code that we need to modify
// add "AM/PM" either if the setting is the default and locale uses it OR if the user unchecked "use 24h format"
if ((main.use24hFormat == Qt.PartiallyChecked && !uses24hFormatByDefault) || main.use24hFormat == Qt.Unchecked) {
result += "\n" + amPm;
}
note the substitution of the space character with the \n
sting, this brings the AM/PM text onto a new line without disturbing the scripts ability to process the time format correctly as the 12hr format.
if you want to further minimize the visual impact of the AM/PM, you can also edit the definition of the amPm variable as so
var amPm = "a";
this will switch it to lower case and give a bit more visual space below the time value… note that the Ignotum font does not have lower case, and so defeats this mod.
so this workaround mod is working for me and has even allowed me to narrow my vertical task bar a bit more and still be able to read the clock.
enjoy.