Skip to main content

embedded_wg_display/runtime/host_api/
clocks.rs

1#![doc = "Implementation of the `clocks` WIT interface.\n\n```wit"]
2#![doc = include_str!("wit/clocks.wit")]
3#![doc = "```"]
4use crate::runtime::WidgetState;
5use crate::runtime::widget::widget::clocks::{self, Datetime};
6use crate::util::globals;
7
8impl clocks::Host for WidgetState {
9    /// returns the current UTC time as [`Datetime`] since the Unix epoch.
10    fn now(&mut self) -> clocks::Datetime {
11        globals::now().unwrap_or(Datetime {
12            seconds: 0,
13            nanoseconds: 0,
14        })
15    }
16}