~tiagosh/dialer-app/greeter-refactor

« back to all changes in this revision

Viewing changes to src/qml/LiveCallPage/StopWatch.qml

  • Committer: Tiago Salem Herrmann
  • Date: 2015-01-08 21:23:40 UTC
  • mfrom: (323.2.7 dialer-app)
  • Revision ID: tiago.herrmann@canonical.com-20150108212340-i9vfrxajyzn4ror6
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import Ubuntu.Components 1.1
21
21
 
22
22
Item {
23
 
    function pad(text, length) {
24
 
        while (text.length < length) text = '0' + text;
25
 
        return text;
26
 
    }
27
23
 
28
24
    property int time: 0
29
25
    property string elapsed: {
30
 
        var divisor_for_minutes = time % (60 * 60);
31
 
        var minutes = String(Math.floor(divisor_for_minutes / 60));
32
 
 
33
 
        var divisor_for_seconds = divisor_for_minutes % 60;
34
 
        var seconds = String(Math.ceil(divisor_for_seconds));
35
 
 
36
 
        return "%1:%2".arg(pad(minutes, 2)).arg(pad(seconds, 2));
 
26
        var d = new Date(0, 0, 0, 0, 0, time);
 
27
 
 
28
        return d.getHours() == 0 ? Qt.formatTime(d, "mm:ss") :
 
29
            Qt.formatTime(d, "h:mm:ss");
37
30
    }
38
31
}