Skip to main content

format_duration_until

Function format_duration_until 

Source
pub fn format_duration_until(reset_unix: i64, now_unix: i64) -> String
Expand description

Formats the time remaining until reset_unix as a compact human string.

Returns “now” when the reset is in the past or under a minute away (clamped at 0), otherwise the two most significant units: “13m”, “2h13m”, or “4d2h”.

§Examples

use vibe_coding_tracker::utils::format_duration_until;

assert_eq!(format_duration_until(100, 100), "now");
assert_eq!(format_duration_until(100 + 13 * 60, 100), "13m");
assert_eq!(format_duration_until(100 + 2 * 3600 + 13 * 60, 100), "2h13m");
assert_eq!(format_duration_until(100 + 4 * 86400 + 2 * 3600, 100), "4d2h");