Code review comment for lp:~pkunal-parmar/ubuntu-calendar-app/TimeLineView

Revision history for this message
Olivier Tilloy (osomon) wrote :

> 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:

  Label {
    id: timeLabel
    text: new Date(0, 0, 0, index).toLocaleTimeString(Qt.locale(), "HH:mm")
  }

review: Needs Fixing

« Back to merge proposal