Switch from MM:SS to HH:MM:SS duration representation if needed

* Contidionally switch from MM:SS to HH:MM:SS duration representation if needed.

* Correct tiny style issue.

* --amend
This commit is contained in:
Thomas Frans
2023-02-17 09:22:12 +01:00
committed by GitHub
parent 829b799cc5
commit a3c4989571
5 changed files with 27 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ use std::fmt;
use std::sync::{Arc, RwLock};
use crate::config;
use crate::utils::ms_to_hms;
use chrono::{DateTime, Utc};
use rspotify::model::album::FullAlbum;
use rspotify::model::track::{FullTrack, SavedTrack, SimplifiedTrack};
@@ -72,9 +73,7 @@ impl Track {
}
pub fn duration_str(&self) -> String {
let minutes = self.duration / 60_000;
let seconds = (self.duration / 1000) % 60;
format!("{minutes:02}:{seconds:02}")
ms_to_hms(self.duration)
}
}