Add real-time clock to home automation demo (#8390)

This commit is contained in:
Tasuku Suzuki 2025-05-08 19:19:03 +09:00 committed by GitHub
parent 6ba3b8586e
commit 0051c95b1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 4 deletions

View file

@ -6,5 +6,21 @@ import * as slint from "slint-ui";
const ui = slint.loadFile("../ui/demo.slint");
const window = new ui.AppWindow();
const api = window.Api;
const date = api.current_date;
const time = api.current_time;
const timer = setInterval(() => {
const now = new Date();
date.year = now.getFullYear();
date.month = now.getMonth() + 1;
date.day = now.getDate();
api.current_date = date;
time.hour = now.getHours();
time.minute = now.getMinutes();
time.second = now.getSeconds();
api.current_time = time;
}, 1000);
await window.run();
clearInterval(timer);