MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / current_time_components

Function current_time_components

nodedb/src/control/security/conditional.rs:238–248  ·  view source on GitHub ↗

Get current hour (0-23) and weekday (0=Sunday).

()

Source from the content-addressed store, hash-verified

236
237/// Get current hour (0-23) and weekday (0=Sunday).
238fn current_time_components() -> (u8, u8) {
239 let secs = std::time::SystemTime::now()
240 .duration_since(std::time::UNIX_EPOCH)
241 .unwrap_or_default()
242 .as_secs();
243 // Approximate: UTC hour and day-of-week from epoch.
244 let hour = ((secs % 86_400) / 3600) as u8;
245 // Epoch was Thursday (4). Days since epoch mod 7.
246 let day = ((secs / 86_400 + 4) % 7) as u8;
247 (hour, day)
248}
249
250/// Parse "HH:MM" to hour.
251fn parse_hour(s: &str) -> u8 {

Callers 1

evaluate_conditionsFunction · 0.85

Calls 2

nowFunction · 0.85
duration_sinceMethod · 0.80

Tested by

no test coverage detected