active-time 0.1.2

A Rust crate to find out the current amount of time the system has been active, excluding time spent hibernating/sleeping.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::{time::{Duration, Instant}, thread::sleep};

use active_time::active_time;

fn main() -> std::io::Result<()> {
    println!("Start");

    let before_active = active_time()?;
    let before = Instant::now();
    sleep(Duration::from_secs(100)); // put your pc to sleep mode here
    let after_active = active_time()?;
    println!("Active time: {:?}", after_active - before_active);
    println!("Actual time: {:?}", before.elapsed());
    Ok(())
}