Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- for s in vec![1, 3, 20, 61, 3601, 67823430] {
- println!("{} -> {}", s, duration(s));
- }
- }
- fn duration(s: u64) -> String {
- vec![s / 60 / 60, (s / 60) % 60, s % 60]
- .into_iter()
- .skip_while(|c| *c == 0)
- .map(|c| format!("{:02}", c))
- .collect::<Vec<String>>()
- .join(":")
- }
Add Comment
Please, Sign In to add comment