kobo_core/device/clock.rs
1//! Wall-clock time for the on-screen clock (shells out to `date` for the
2//! locale-correct 12-hour format).
3
4use std::process::Command;
5
6pub fn current_clock() -> String {
7 Command::new("date")
8 .args(["+%-I:%M %p"])
9 .output()
10 .ok()
11 .and_then(|o| String::from_utf8(o.stdout).ok())
12 .map(|s| s.trim().to_string())
13 .unwrap_or_else(|| "--:--".to_string())
14}