pub struct DateComponents {
pub year: i32,
pub month: u8,
pub day: u8,
pub hour: u8,
pub minute: u8,
pub second: u8,
pub offset_minutes: i32,
}Expand description
Platform-agnostic time source abstraction for the Uni interpreter.
This trait allows embedding applications to provide date/time information without requiring the interpreter to depend on specific time libraries. Different platforms can implement this trait using their available hardware timers, RTCs, or system clocks.
The interface matches what RTC (Real-Time Clock) chips typically provide: date components (year, month, day, hour, minute, second) plus timezone offset.
§Examples
use uni_core::{TimeSource, DateComponents};
struct SystemTime;
impl TimeSource for SystemTime {
fn now(&self) -> DateComponents {
// On std platforms, use chrono or std::time
DateComponents {
year: 2025,
month: 10,
day: 18,
hour: 14,
minute: 30,
second: 0,
offset_minutes: 0, // UTC
}
}
}Date and time components, matching what RTC chips provide
Fields§
§year: i32§month: u8§day: u8§hour: u8§minute: u8§second: u8§offset_minutes: i32Trait Implementations§
Source§impl Clone for DateComponents
impl Clone for DateComponents
Source§fn clone(&self) -> DateComponents
fn clone(&self) -> DateComponents
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DateComponents
impl Debug for DateComponents
impl Copy for DateComponents
Auto Trait Implementations§
impl Freeze for DateComponents
impl RefUnwindSafe for DateComponents
impl Send for DateComponents
impl Sync for DateComponents
impl Unpin for DateComponents
impl UnwindSafe for DateComponents
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more