aboutsummaryrefslogtreecommitdiffstats
path: root/DateBox.qml
blob: 9b7a48f6f5bee278959c2b0a90752c341f8d9af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: GPL-3.0+
// Copyright (C) 2021 AISIN CORPORATION

import QtQuick 2.2

Item {
    id: dateBox
    property color timeColor: Qt.rgba(0.9,0.9,0.9,0.9)
    property bool flashing: false
    property string text: ""
    property int pixSize: 20
    property var locale: Qt.locale()
    property string dateString: ""

    Timer {
        id: flashTimer
        interval: 1000
        running: true
        repeat: true
        onTriggered: {
            var currentDate = new Date();
            var formatString = "hh:mm ap";
            dateBoxText.text = currentDate.toLocaleTimeString(locale,formatString);
        }
    }

    Text {
        id: dateBoxText
        visible: true
        font.pixelSize: pixSize
        color: timeColor
        horizontalAlignment: Text.AlignRight
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: parent.verticalCenter
    }
}