Get current hour (0-23) and weekday (0=Sunday).
()
| 236 | |
| 237 | /// Get current hour (0-23) and weekday (0=Sunday). |
| 238 | fn 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. |
| 251 | fn parse_hour(s: &str) -> u8 { |
no test coverage detected