Skip to main content

shoko_screen_timer/
lib.rs

1use std::time::{SystemTime, UNIX_EPOCH};
2
3pub fn get_active() -> u64 {
4    SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()
5}
6
7pub fn format_screen_time(active_seconds: u64) -> String {
8    let hours = active_seconds / 3600;
9    let minutes = (active_seconds % 3600) / 60;
10    let seconds = active_seconds % 60;
11
12    format!(
13    "{{\"text\": \"{:02}:{:02}:{:02}\", \"tooltip\": \"Screen Time\" }}",
14    hours, minutes, seconds)
15}