https://github.com/cleancut/rusty_time
A simple timer
https://github.com/cleancut/rusty_time
Last synced: 5 months ago
JSON representation
A simple timer
- Host: GitHub
- URL: https://github.com/cleancut/rusty_time
- Owner: CleanCut
- Created: 2021-03-15T00:38:15.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-11T00:13:47.000Z (over 2 years ago)
- Last Synced: 2025-08-19T12:25:10.438Z (6 months ago)
- Language: Rust
- Size: 20.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: license/APACHE
Awesome Lists containing this project
README
# Rusty Time
A simple timer. See also the [reference docs on docs.rs](https://docs.rs/rusty_time/latest/rusty_time/)
## Quick Start
Add `rusty_timer` to your `Cargo.toml` with:
```shell
cargo add rusty_timer
```
Then use it like this:
```rust
fn main() {
let mut timer = Timer::new(Duration::from_secs_f32(1.5));
let mut start_time = Instant::now();
loop {
timer.tick(start_time.elapsed());
start_time = Instant::now();
println!(
"Time on timer: {:.2}s ({:.1}%)",
timer.remaining().as_secs_f32(),
timer.percent_left() * 100.0
);
if timer.just_finished() {
break;
}
}
println!("Timer finished!");
}
```
## Contribution
All contributions are assumed to be dual-licensed under MIT/Apache-2.
## License
Distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [license/APACHE](license/APACHE) and [license/MIT](license/MIT).
## Sponsor
If you like `rusty_time`, please consider [sponsoring me](https://github.com/sponsors/CleanCut) on GitHub. 💖