summaryrefslogtreecommitdiff
path: root/services/TimeDate.qml
blob: fab2beb07a35ecd8b3528477782ac053e3336b7b (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
pragma Singleton

import Quickshell
import QtQuick

Singleton {
    id: root
    readonly property string time: {
        // fuck you qt give me my 12 hr time
        var h = clock.date.getHours();
        var m = clock.date.getMinutes();
        var s = clock.date.getSeconds();
        h = h % 12;
        if (h === 0)
            h = 12;
        return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
    }
    readonly property int hours: {
        var h = clock.date.getHours();
        h = h % 12;
        if (h === 0)
            h = 12;
        return h;
    }
    readonly property int minutes: clock.date.getMinutes()
    readonly property int seconds: clock.date.getSeconds()

    readonly property string date: Qt.formatDateTime(clock.date, "dddd dd/MM")

    SystemClock {
        id: clock
        precision: SystemClock.Seconds
    }
}