Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use humantime crate in main #242

Open
Luthaf opened this issue May 14, 2018 · 0 comments
Open

Use humantime crate in main #242

Luthaf opened this issue May 14, 2018 · 0 comments

Comments

@Luthaf
Copy link
Member

Luthaf commented May 14, 2018

We currently manually format the elapsed time manually in the output log:

lumol/src/bin/lumol.rs

Lines 66 to 87 in 0f6efbd

fn format_elapsed(elapsed: Duration) -> String {
if elapsed.num_weeks() > 0 {
let h = elapsed.num_hours() % 24;
let d = elapsed.num_days() % 7;
let w = elapsed.num_weeks();
format!("{} weeks {} days {}h", w, d, h)
} else if elapsed.num_days() > 0 {
let m = elapsed.num_minutes() % 60;
let h = elapsed.num_hours() % 24;
let d = elapsed.num_days();
format!("{} days {}h {}min", d, h, m)
} else if elapsed.num_hours() > 0 {
let s = elapsed.num_seconds() % 60;
let m = elapsed.num_minutes() % 60;
let h = elapsed.num_hours();
format!("{}h {}min {}s", h, m, s)
} else {
let s = elapsed.num_seconds() % 60;
let m = elapsed.num_minutes();
format!("{}min {}s", m, s)
}
}

This code could be replaced by using the humantime crate instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant