time-hms

Crates.iotime-hms
lib.rstime-hms
version0.3.1
sourcesrc
created_at2023-01-24 07:43:15.494589
updated_at2023-09-24 17:18:35.15684
descriptionConvert a duration in seconds to a representation in hours, minutes and seconds
homepage
repositoryhttps://github.com/ad-8/time-hms
max_upload_size
id766500
size4,549
(ad-8)

documentation

README

About

Easily parse a duration represented in seconds to a more human-readable representation in hours, minutes and seconds.

Why?

It's a simple functionality that I needed across different applications. I also wanted to learn how to publish a library on crates.io.

Usage

use time_hms::TimeHms;

let t = TimeHms::new(3723);

// 3723 seconds equal 1 hour, 2 minutes and 3 seconds
assert_eq!(t.h(), 1);
assert_eq!(t.m(), 2);
assert_eq!(t.s(), 3);

// A default way to format! / println! is included
assert_eq!(format!("{}", t), "01:02:03")
Commit count: 30

cargo fmt