mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00
Add real-time clock to home automation demo (#8390)
This commit is contained in:
parent
6ba3b8586e
commit
0051c95b1b
4 changed files with 46 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue