> As David suggested, I tried to use code from Clock source code. I am using
> following code now. Does it looks ok ?
>
> My implementation is only hourToLocaleString() this function. Other are copied
> from Clock.
>
> function numberToLocaleString(num) {
> return Number(num).toLocaleString(Qt.locale(), "f", 0)
> }
>
> function zeroleft ( number, zeroCount ) {
> var resstring = numberToLocaleString(number.toString());
> var numchart = zeroCount;
> var numberlength = resstring.length;
> for (var i = numberlength; i < numchart; i++) {
> resstring = numberToLocaleString("0") + resstring;
> }
> return resstring;
> }
>
> function hourToLocaleString(hour) {
> return zeroleft(hour,2)+":"+ zeroleft(0,2);
> }
If that is the way the Clock app does it, then it’s wrong. The zeroleft function is not i18n friendly, and there’s a much shorter solution:
> As David suggested, I tried to use code from Clock source code. I am using ing() this function. Other are copied tring(num) { num).toLocaleSt ring(Qt. locale( ), "f", 0) tring(number. toString( )); tring(" 0") + resstring; ing(hour) { hour,2) +":"+ zeroleft(0,2);
> following code now. Does it looks ok ?
>
> My implementation is only hourToLocaleStr
> from Clock.
>
> function numberToLocaleS
> return Number(
> }
>
> function zeroleft ( number, zeroCount ) {
> var resstring = numberToLocaleS
> var numchart = zeroCount;
> var numberlength = resstring.length;
> for (var i = numberlength; i < numchart; i++) {
> resstring = numberToLocaleS
> }
> return resstring;
> }
>
> function hourToLocaleStr
> return zeroleft(
> }
If that is the way the Clock app does it, then it’s wrong. The zeroleft function is not i18n friendly, and there’s a much shorter solution:
Label { toLocaleTimeStr ing(Qt. locale( ), "HH:mm")
id: timeLabel
text: new Date(0, 0, 0, index).
}