MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / realtime

Function realtime

src/clock.rs:18–29  ·  view source on GitHub ↗

This is a public function that is responsible for defining "real-time". This function uses the CMOS of the system to calculate the time.

()

Source from the content-addressed store, hash-verified

16// This is a public function that is responsible for defining "real-time". This function uses the CMOS of the
17// system to calculate the time.
18pub fn realtime() -> f64
19{
20 let rtc = CMOS::new().rtc();
21 let timestamp = 86400 * d_before_yr(rtc.year as u64)
22 + 86400 * d_before_mon(rtc.year as u64, rtc.month as u64)
23 + 86400 * (rtc.day - 1) as u64
24 + 3600 * rtc.hour as u64
25 + 60 * rtc.minute as u64
26 + rtc.second as u64;
27 let fract = time::time_between_ticks() * (time::tick() - time::last_rtcupdate()) as f64;
28 (timestamp as f64) + fract
29}
30
31
32// This is a public function that provides a method for returning the time that the system has been

Callers 4

rtFunction · 0.85
item_updateMethod · 0.85
new_itemMethod · 0.85
update_itemMethod · 0.85

Calls 6

d_before_yrFunction · 0.85
d_before_monFunction · 0.85
time_between_ticksFunction · 0.85
tickFunction · 0.85
last_rtcupdateFunction · 0.85
rtcMethod · 0.80

Tested by

no test coverage detected