#seconds #duration-seconds #time #hours #minutes #time-parser #hms

time-hms

Convert a duration in seconds to a representation in hours, minutes and seconds

7 releases

0.3.1 Sep 24, 2023
0.3.0 Feb 1, 2023
0.2.1 Jan 31, 2023
0.1.3 Jan 31, 2023

#209 in Date and time

Download history 3/week @ 2024-02-23 1/week @ 2024-03-01 1/week @ 2024-03-08 1/week @ 2024-03-22 75/week @ 2024-03-29

77 downloads per month

MIT license

5KB
78 lines

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")

No runtime deps