[digital-clock] Fix display of seconds with certain locales

Currently, "Show seconds" has no effect with certain locales (C e.g.)
that already contain the seconds in the ShortFormat.
The reason is that the seconds are only added to the format string
that's used to display the time if they are not part of timeFormatString
already (which is not used at all for the display).

This patch fixes that check and adds them only depending on the
showSeconds config option.

REVIEW: 127623
wilder-5.14
Wolfgang Bauer 10 years ago
parent f86fa3cd77
commit a7a22de14c
  1. 8
      applets/digital-clock/package/contents/ui/DigitalClock.qml

@ -478,11 +478,7 @@ Item {
// and Short does not provide seconds. So if seconds are enabled, we need to add it here.
//
// What happens here is that it looks for the delimiter between "h" and "m", takes it
// and appends it after "mm" and then appends "ss" for the seconds. Also it checks
// if the format string already does not contain the seconds part.
//
// It can happen that Qt uses the 'C' locale (it's a fallback) and that locale
// has always ":ss" part in ShortFormat, so we need to remove it.
// and appends it after "mm" and then appends "ss" for the seconds.
function timeFormatCorrection(timeFormatString) {
var regexp = /(hh*)(.+)(mm)/i
var match = regexp.exec(timeFormatString);
@ -498,7 +494,7 @@ Item {
// when uppercase H is used for hours, needs to be h or hh, so toLowerCase()
var result = hours.toLowerCase() + delimiter + minutes;
if (main.showSeconds && timeFormatString.indexOf('s') == -1) {
if (main.showSeconds) {
result += delimiter + seconds;
}

Loading…
Cancel
Save