pragma Singleton import Quickshell Singleton { property alias enabled: clock.enabled readonly property date date: clock.date readonly property int hours: clock.hours readonly property int minutes: clock.minutes readonly property int seconds: clock.seconds SystemClock { id: clock precision: SystemClock.Seconds } function format(fmt: string): string { return Qt.formatDateTime(clock.date, fmt); } function formatSeconds(s: int, includeSecs = false): string { let min = Math.floor(s / 60); let hr = Math.floor(min / 60); let day = Math.floor(hr / 24); let week = Math.floor(day / 7); let year = Math.floor(day / 365); s = s % 60; min = min % 60; hr = hr % 24; day = day % 7; week = week % 52; let comps = []; if (year > 0) comps.push(`${year}y`); if (week > 0) comps.push(`${week}w`); if (day > 0) comps.push(`${day}d`); if (hr > 0) comps.push(`${hr}h`); if (min > 0) comps.push(`${min}m`); if (includeSecs && s > 0) comps.push(`${s}s`); if (comps.length === 0) return ""; else return comps.join(" "); } }